{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "D:\\Anaconda3\\lib\\site-packages\\gensim\\utils.py:865: UserWarning: detected Windows; aliasing chunkize to chunkize_serial\n",
      "  warnings.warn(\"detected Windows; aliasing chunkize to chunkize_serial\")\n"
     ]
    }
   ],
   "source": [
    "# coding:utf-8\n",
    "import gensim\n",
    "model_path = \"./model/job_title_word2vec.model\"\n",
    "model = gensim.models.Word2Vec.load(model_path)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "def show_word_most_similar(word, model, topn):\n",
    "    result_word2vec_list = model.most_similar(word, topn=topn)\n",
    "    i = 0\n",
    "    for wv in result_word2vec_list:\n",
    "        i+=1\n",
    "        print(\"%-5s%-10s%-10s\" % (i, wv[0], wv[1]))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {
    "collapsed": false,
    "scrolled": true
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "1    java开发    0.6753628253936768\n",
      "2    php       0.6690933108329773\n",
      "3    程序员       0.6263120770454407\n",
      "4    ios开发     0.6101993322372437\n",
      "5    php开发     0.5862185955047607\n",
      "6    安卓开发      0.5664030313491821\n",
      "7    java程序员   0.5655223727226257\n",
      "8    c++       0.5587760806083679\n",
      "9    自动化测试     0.5531591176986694\n",
      "10   c#        0.5460507869720459\n"
     ]
    }
   ],
   "source": [
    "show_word_most_similar(\"java\", model, 10)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "# 生成txt格式的模型\n",
    "wv = model.wv\n",
    "wv.save_word2vec_format(\"./word2vec_model/job_title_word2vec_google_format.model\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "15553"
      ]
     },
     "execution_count": 17,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "wv = model.wv\n",
    "len(wv.vocab)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "vocab_word = model.wv.index2word"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 40,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['双休',\n",
       " '应届生',\n",
       " '助理',\n",
       " '接受',\n",
       " '五险一金',\n",
       " '可',\n",
       " '专员',\n",
       " '诚聘',\n",
       " '销售',\n",
       " '工程师',\n",
       " '经理',\n",
       " '高薪',\n",
       " '实习生',\n",
       " '带薪',\n",
       " '底薪',\n",
       " '补助',\n",
       " '文员',\n",
       " '提成',\n",
       " '补贴',\n",
       " '绩效',\n",
       " '会计',\n",
       " '做',\n",
       " '销售代表',\n",
       " '周末',\n",
       " '手机',\n",
       " '奖金',\n",
       " '旅游',\n",
       " '六',\n",
       " '年',\n",
       " '朝九晚',\n",
       " '招聘',\n",
       " '员',\n",
       " '假',\n",
       " '年底双薪',\n",
       " '主管',\n",
       " '住宿',\n",
       " '经验',\n",
       " '食宿',\n",
       " '客服',\n",
       " '演员',\n",
       " '节日',\n",
       " '实习',\n",
       " '员工',\n",
       " '普工',\n",
       " '销售经理',\n",
       " '高',\n",
       " '急聘',\n",
       " '五险',\n",
       " '行政专员',\n",
       " '行政',\n",
       " '工作',\n",
       " '全勤奖',\n",
       " '包吃',\n",
       " '绩效奖金',\n",
       " '人',\n",
       " '培训',\n",
       " '出纳',\n",
       " '学徒',\n",
       " '住',\n",
       " '直招',\n",
       " '师',\n",
       " '办公室文员',\n",
       " '财务助理',\n",
       " '包',\n",
       " '月薪',\n",
       " '人事专员',\n",
       " '交通',\n",
       " '福利',\n",
       " '采购专员',\n",
       " '朝九晚五',\n",
       " '提供',\n",
       " '财务',\n",
       " '无需',\n",
       " '免费',\n",
       " '行政助理',\n",
       " '跟组',\n",
       " '聘',\n",
       " '随时',\n",
       " '高级',\n",
       " '班车',\n",
       " '晋升',\n",
       " '电工',\n",
       " '餐补',\n",
       " '公司',\n",
       " '急招',\n",
       " '厨师',\n",
       " '客户经理',\n",
       " '无责',\n",
       " '台',\n",
       " '招',\n",
       " '老师',\n",
       " '包住',\n",
       " '顾问',\n",
       " '前',\n",
       " '补充',\n",
       " '体验',\n",
       " '项目',\n",
       " '医疗保险',\n",
       " 'app',\n",
       " '艺人',\n",
       " '软件',\n",
       " '船员',\n",
       " '合伙人',\n",
       " '储备干部',\n",
       " 'java',\n",
       " '房补',\n",
       " '无',\n",
       " '总监',\n",
       " '定期',\n",
       " '加班',\n",
       " '体检',\n",
       " '元',\n",
       " '电焊工',\n",
       " '试用',\n",
       " '人事助理',\n",
       " '搬运工',\n",
       " '跟单员',\n",
       " '有',\n",
       " '月',\n",
       " '化妆',\n",
       " '起',\n",
       " '的',\n",
       " '业务员',\n",
       " '及',\n",
       " '区域',\n",
       " '电话销售',\n",
       " '大',\n",
       " '人员',\n",
       " '年终奖',\n",
       " '事',\n",
       " '轻松',\n",
       " '丨',\n",
       " '人力资源专员',\n",
       " '应届毕业生',\n",
       " '不',\n",
       " '课程顾问',\n",
       " '薪资',\n",
       " '链家',\n",
       " '平面设计',\n",
       " '摄影',\n",
       " 'iphone',\n",
       " '项目经理',\n",
       " 'ipad',\n",
       " '客服专员',\n",
       " '平安',\n",
       " '基础',\n",
       " 'app试用',\n",
       " '金融',\n",
       " '置业顾问',\n",
       " '录入员',\n",
       " '资料',\n",
       " '优先',\n",
       " 'k',\n",
       " '计件',\n",
       " '临时',\n",
       " '岗',\n",
       " '后勤',\n",
       " '城',\n",
       " '企业',\n",
       " '银行',\n",
       " '万',\n",
       " '司机',\n",
       " '8k',\n",
       " '市',\n",
       " '区域经理',\n",
       " '销售精英',\n",
       " '储备',\n",
       " '5k',\n",
       " '招聘专员',\n",
       " '软件开发',\n",
       " '采购助理',\n",
       " '内勤',\n",
       " '公寓',\n",
       " '设计师',\n",
       " '线',\n",
       " '店长',\n",
       " '销售助理',\n",
       " '会计助理',\n",
       " '多项',\n",
       " '好',\n",
       " '北京',\n",
       " '集团',\n",
       " '在',\n",
       " '业务',\n",
       " '技术',\n",
       " '4k',\n",
       " '应',\n",
       " '中国',\n",
       " '保安',\n",
       " '秘书',\n",
       " '待遇',\n",
       " '诚招',\n",
       " '网络',\n",
       " '焊工',\n",
       " '方向',\n",
       " '等',\n",
       " '用',\n",
       " '物流专员',\n",
       " '设计',\n",
       " '地',\n",
       " '销售主管',\n",
       " '零',\n",
       " '叉车工',\n",
       " '中',\n",
       " '接送',\n",
       " '应届',\n",
       " '市场专员',\n",
       " '负责',\n",
       " '仓库管理员',\n",
       " '千',\n",
       " '外贸业务员',\n",
       " 'it',\n",
       " '弹性',\n",
       " '国企',\n",
       " '开发',\n",
       " '出纳员',\n",
       " '年薪',\n",
       " '网络销售',\n",
       " '导演',\n",
       " '销售顾问',\n",
       " '就',\n",
       " '无责任底薪',\n",
       " '和',\n",
       " '技术员',\n",
       " '享',\n",
       " '总经理助理',\n",
       " '销售总监',\n",
       " '亦可',\n",
       " '初级',\n",
       " '代表',\n",
       " '销售工程师',\n",
       " '行政文员',\n",
       " '综合',\n",
       " '6k',\n",
       " '下载',\n",
       " '时间',\n",
       " '外贸',\n",
       " '总经理',\n",
       " '你',\n",
       " '模特',\n",
       " '手',\n",
       " '文职',\n",
       " '服装',\n",
       " '管理',\n",
       " '教师',\n",
       " '区域销售经理',\n",
       " '业务经理',\n",
       " '以上',\n",
       " '美工',\n",
       " '人人',\n",
       " '开发工程师',\n",
       " '部',\n",
       " '上海',\n",
       " '会计师',\n",
       " '运营',\n",
       " '游戏',\n",
       " '通讯',\n",
       " '团队',\n",
       " '国',\n",
       " '空间',\n",
       " '店员',\n",
       " '出',\n",
       " '互联网',\n",
       " '施工员',\n",
       " '房产销售',\n",
       " '摄影师',\n",
       " 'java开发',\n",
       " '房产经纪人',\n",
       " '六险',\n",
       " '管培生',\n",
       " '月入',\n",
       " '化妆师',\n",
       " '专业',\n",
       " '区',\n",
       " '文案策划',\n",
       " '直聘',\n",
       " '分红',\n",
       " '限',\n",
       " '电商',\n",
       " '中心',\n",
       " '资深',\n",
       " '季度',\n",
       " '平台',\n",
       " '操作工',\n",
       " '创业',\n",
       " '国际',\n",
       " '渠道',\n",
       " '工',\n",
       " '采购',\n",
       " '招商',\n",
       " '岗位',\n",
       " '讲师',\n",
       " '结算',\n",
       " '营销',\n",
       " '主任',\n",
       " '行业',\n",
       " '新手',\n",
       " '经理助理',\n",
       " '物流',\n",
       " '平面设计师',\n",
       " '市场',\n",
       " '工程',\n",
       " '新',\n",
       " '英语',\n",
       " '售后',\n",
       " '行政主管',\n",
       " '一金',\n",
       " '转行',\n",
       " '猎头顾问',\n",
       " '过万',\n",
       " '空闲',\n",
       " '日',\n",
       " '精英',\n",
       " 'wifi',\n",
       " '产品经理',\n",
       " '地点',\n",
       " '运维工程师',\n",
       " '险',\n",
       " '交易员',\n",
       " '招募',\n",
       " '剧组',\n",
       " '社保',\n",
       " '新媒体运营',\n",
       " '分公司',\n",
       " '店',\n",
       " '服务员',\n",
       " '预算员',\n",
       " '兼职',\n",
       " '人力资源',\n",
       " '优秀',\n",
       " '教育',\n",
       " '招商经理',\n",
       " '应用',\n",
       " '咨询',\n",
       " '跟单',\n",
       " '均',\n",
       " '办公室',\n",
       " '金',\n",
       " '办公',\n",
       " '销售业务',\n",
       " '文案',\n",
       " '产品',\n",
       " '就近',\n",
       " '招生',\n",
       " '总部',\n",
       " '淘宝',\n",
       " '营业员',\n",
       " '年终',\n",
       " '小',\n",
       " '酒店',\n",
       " '业务代表',\n",
       " '推广',\n",
       " '软件工程师',\n",
       " '环境',\n",
       " '随船',\n",
       " '拓展',\n",
       " '编辑',\n",
       " '高端',\n",
       " '财务经理',\n",
       " '咨询师',\n",
       " '高温',\n",
       " '技工',\n",
       " '导购',\n",
       " '长',\n",
       " '纯',\n",
       " '客户',\n",
       " '操盘手',\n",
       " '客户代表',\n",
       " '售前',\n",
       " '生产',\n",
       " '群众演员',\n",
       " '资料员',\n",
       " '期货操盘',\n",
       " '市场经理',\n",
       " '经纪人',\n",
       " 'vr',\n",
       " '广告',\n",
       " '淘宝客服',\n",
       " '接待',\n",
       " '赚取',\n",
       " '零花钱',\n",
       " '人事主管',\n",
       " '渠道经理',\n",
       " '市场推广',\n",
       " '区域销售',\n",
       " '男女',\n",
       " '天',\n",
       " '策划',\n",
       " '能',\n",
       " '培养',\n",
       " '网络管理员',\n",
       " '3k',\n",
       " '课程',\n",
       " '会计主管',\n",
       " '医药代表',\n",
       " '网页设计',\n",
       " '在线客服',\n",
       " '海外',\n",
       " '体验员',\n",
       " '稳定',\n",
       " '平面',\n",
       " '保险',\n",
       " '运营专员',\n",
       " '投资',\n",
       " '上市公司',\n",
       " '服务',\n",
       " '团建',\n",
       " '前台接待',\n",
       " '收入',\n",
       " '行政人事',\n",
       " '邮轮',\n",
       " '兼',\n",
       " '汽车',\n",
       " '招聘助理',\n",
       " '转正',\n",
       " '行政经理',\n",
       " '快',\n",
       " '商务',\n",
       " '差',\n",
       " '技术支持',\n",
       " '管理员',\n",
       " '采购员',\n",
       " '渠道销售',\n",
       " '高额',\n",
       " '物业',\n",
       " '总',\n",
       " '信贷',\n",
       " '校区',\n",
       " '上',\n",
       " '欢迎',\n",
       " '省区',\n",
       " '督导',\n",
       " '急',\n",
       " '贷款',\n",
       " '发展',\n",
       " '软件测试',\n",
       " '仓管',\n",
       " '电气工程师',\n",
       " '电话',\n",
       " '路费',\n",
       " '初',\n",
       " '央企',\n",
       " 'web前端开发',\n",
       " '房产',\n",
       " '班',\n",
       " '信息',\n",
       " '全职',\n",
       " 'ui',\n",
       " '医疗',\n",
       " '外',\n",
       " '大客户经理',\n",
       " '媒体',\n",
       " '年底',\n",
       " '事业部',\n",
       " '车险',\n",
       " '内',\n",
       " '猎头',\n",
       " '人力资源经理',\n",
       " '信用卡',\n",
       " '主播',\n",
       " '打卡',\n",
       " '强',\n",
       " '全',\n",
       " '研发工程师',\n",
       " '环保',\n",
       " '咨询顾问',\n",
       " '网络推广',\n",
       " '天猫',\n",
       " '财务会计',\n",
       " '总裁助理',\n",
       " '测量员',\n",
       " '暑假工',\n",
       " '副',\n",
       " '日语',\n",
       " '英语老师',\n",
       " '一',\n",
       " 'ui设计师',\n",
       " '外汇交易',\n",
       " '人事经理',\n",
       " '物流助理',\n",
       " '催收',\n",
       " '分配',\n",
       " '新人',\n",
       " '文秘',\n",
       " '保底',\n",
       " '手游',\n",
       " '电销',\n",
       " '部门',\n",
       " '外贸专员',\n",
       " '代理',\n",
       " '房地产',\n",
       " '计划',\n",
       " '档案管理',\n",
       " '维修',\n",
       " '土建',\n",
       " '员工福利',\n",
       " '财务主管',\n",
       " '优厚',\n",
       " '微信',\n",
       " 'android',\n",
       " '培训讲师',\n",
       " '挑战',\n",
       " '早九晚',\n",
       " '股票',\n",
       " '房地产销售',\n",
       " '后',\n",
       " '销售内勤',\n",
       " '二',\n",
       " '市场部',\n",
       " '理财规划师',\n",
       " '机械工程师',\n",
       " '运维',\n",
       " '护士',\n",
       " '安排',\n",
       " '门店',\n",
       " '非',\n",
       " '贸易',\n",
       " '审核',\n",
       " '学',\n",
       " '质检员',\n",
       " '水果',\n",
       " '通告',\n",
       " '测试工程师',\n",
       " '品牌',\n",
       " '亚马逊',\n",
       " '财务总监',\n",
       " '淘宝美工',\n",
       " '加盟',\n",
       " '叉车',\n",
       " '大客户销售',\n",
       " '安全员',\n",
       " '各项',\n",
       " '道',\n",
       " '专业培训',\n",
       " '津贴',\n",
       " '各',\n",
       " '才',\n",
       " '电话客服',\n",
       " '储备经理',\n",
       " '招商专员',\n",
       " '销售人员',\n",
       " '来',\n",
       " 'php',\n",
       " 'ui设计',\n",
       " '接收',\n",
       " '午餐',\n",
       " '外汇',\n",
       " '前台文员',\n",
       " '节假日',\n",
       " '聘请',\n",
       " '类',\n",
       " '简单',\n",
       " '运营经理',\n",
       " '收银员',\n",
       " '培训生',\n",
       " '仓库',\n",
       " '小时',\n",
       " '售后服务',\n",
       " '市场营销',\n",
       " '薪',\n",
       " '餐饮',\n",
       " '人力资源主管',\n",
       " '操作',\n",
       " '老板',\n",
       " '毕业生',\n",
       " '现场',\n",
       " '英语教师',\n",
       " 'c++',\n",
       " '研发',\n",
       " '商务专员',\n",
       " '应用软件',\n",
       " '翻译',\n",
       " '助教',\n",
       " '押运',\n",
       " '人寿',\n",
       " '运营总监',\n",
       " '教务',\n",
       " '电子',\n",
       " '管理培训生',\n",
       " '餐厅',\n",
       " '临床',\n",
       " '技师',\n",
       " '交补',\n",
       " '期货',\n",
       " '电商运营',\n",
       " '销售员',\n",
       " '推广专员',\n",
       " '采暖',\n",
       " '我',\n",
       " '游戏开发',\n",
       " '与',\n",
       " '不限',\n",
       " '分析师',\n",
       " '新戏',\n",
       " '人力资源助理',\n",
       " '上市',\n",
       " '产',\n",
       " '接听',\n",
       " '室内设计师',\n",
       " '商务助理',\n",
       " '计算机',\n",
       " '高新',\n",
       " '培训师',\n",
       " '大区经理',\n",
       " '广州',\n",
       " '上班',\n",
       " '地产',\n",
       " '造价员',\n",
       " '场务',\n",
       " '入',\n",
       " '市场总监',\n",
       " '灯光',\n",
       " '岗前',\n",
       " '自己',\n",
       " '六日',\n",
       " '测试',\n",
       " '正式',\n",
       " '程序员',\n",
       " '技术支持工程',\n",
       " '海员',\n",
       " '培训专员',\n",
       " '临时工',\n",
       " '渠道专员',\n",
       " '外企',\n",
       " '角色',\n",
       " '型',\n",
       " 'hr',\n",
       " '风控',\n",
       " '下午茶',\n",
       " '3d',\n",
       " '英语翻译',\n",
       " '白班',\n",
       " '入职',\n",
       " '采购文员',\n",
       " '影视',\n",
       " '.net',\n",
       " '近海',\n",
       " '质检',\n",
       " '带',\n",
       " '代理商',\n",
       " '安装',\n",
       " '豪华',\n",
       " '一手',\n",
       " '师傅',\n",
       " '内部',\n",
       " '设备',\n",
       " '设计助理',\n",
       " '活动策划',\n",
       " '市场主管',\n",
       " '中级',\n",
       " '法定',\n",
       " '厂区',\n",
       " '当天',\n",
       " '吃',\n",
       " '数据分析师',\n",
       " '工资',\n",
       " '4s店',\n",
       " '绩效考核',\n",
       " '售后客服',\n",
       " '有无',\n",
       " '家装',\n",
       " '海船',\n",
       " '休',\n",
       " '外贸业务',\n",
       " '金融销售',\n",
       " '奖励',\n",
       " '网络工程师',\n",
       " '要求',\n",
       " '定岗',\n",
       " '本',\n",
       " '大学生',\n",
       " '美工设计',\n",
       " '班主任',\n",
       " '学习',\n",
       " '月均',\n",
       " 'otc',\n",
       " '跟',\n",
       " '具',\n",
       " '办公室主任',\n",
       " '水',\n",
       " '跟车',\n",
       " '客户服务',\n",
       " '贸易专员',\n",
       " '连锁',\n",
       " '名',\n",
       " '电气',\n",
       " '驻',\n",
       " '理财顾问',\n",
       " '系统',\n",
       " '机械',\n",
       " '后期制作',\n",
       " '深圳',\n",
       " '便利',\n",
       " '游戏设计',\n",
       " '10k',\n",
       " '职',\n",
       " '电子商务',\n",
       " '图书',\n",
       " '业务助理',\n",
       " '快递',\n",
       " '外贸销售',\n",
       " '移动',\n",
       " '快递员',\n",
       " '副总经理',\n",
       " '古装',\n",
       " '超长',\n",
       " '商务经理',\n",
       " '世界',\n",
       " 'web前端',\n",
       " '金融交易',\n",
       " '乘务员',\n",
       " '丰厚',\n",
       " '证券',\n",
       " '梦',\n",
       " '会',\n",
       " '或',\n",
       " '工程造价',\n",
       " '执行',\n",
       " '宿舍',\n",
       " '采购经理',\n",
       " 'bd',\n",
       " '注册',\n",
       " '派',\n",
       " '维护',\n",
       " '校长',\n",
       " 'qc',\n",
       " '组装',\n",
       " '文案编辑',\n",
       " '教学',\n",
       " '在家',\n",
       " '理财经理',\n",
       " '资料录',\n",
       " '梦想',\n",
       " '新船',\n",
       " '科技',\n",
       " '自动化',\n",
       " '期货交易',\n",
       " '市政',\n",
       " '库管',\n",
       " '硬件工程师',\n",
       " '火热',\n",
       " 'vip',\n",
       " '返',\n",
       " 'manager',\n",
       " '数据分析',\n",
       " '加入',\n",
       " '压力',\n",
       " '试衣',\n",
       " '届',\n",
       " '优',\n",
       " '客服主管',\n",
       " '运营助理',\n",
       " '均薪',\n",
       " '投资顾问',\n",
       " '网络运营',\n",
       " '医生',\n",
       " '实施工程师',\n",
       " '京东',\n",
       " '数学老师',\n",
       " '阿里巴巴',\n",
       " '报销',\n",
       " '自由',\n",
       " '理货员',\n",
       " '合作',\n",
       " '制作',\n",
       " '齐全',\n",
       " '货运',\n",
       " '古装剧',\n",
       " '研究员',\n",
       " '签约',\n",
       " '打',\n",
       " '管家',\n",
       " '服装设计师',\n",
       " '监理',\n",
       " '短期',\n",
       " '副经理',\n",
       " '业务拓展',\n",
       " '美容',\n",
       " '学徒工',\n",
       " '商务司机',\n",
       " '会计文员',\n",
       " '生',\n",
       " '天猫客服',\n",
       " '力',\n",
       " '爱',\n",
       " '成都',\n",
       " '手机软件',\n",
       " '支持',\n",
       " '资源',\n",
       " '在家做',\n",
       " '市场拓展',\n",
       " '管住',\n",
       " '月度',\n",
       " 'hrbp',\n",
       " '单',\n",
       " '店面',\n",
       " '最新',\n",
       " '郑州',\n",
       " '铁',\n",
       " '站',\n",
       " '杭州',\n",
       " '网页',\n",
       " '商品',\n",
       " 'engineer',\n",
       " '奖',\n",
       " '结构工程师',\n",
       " '优才',\n",
       " '做五休',\n",
       " '早教',\n",
       " '医药',\n",
       " '承包',\n",
       " '前端开发',\n",
       " '中介',\n",
       " '送货员',\n",
       " '法务专员',\n",
       " '数据',\n",
       " '处理',\n",
       " '活动',\n",
       " '搬运',\n",
       " '项目助理',\n",
       " '少儿英语',\n",
       " '职位',\n",
       " '软件测试工程',\n",
       " '营销总监',\n",
       " '各种',\n",
       " '基金',\n",
       " '云计算',\n",
       " '建筑',\n",
       " '船',\n",
       " '业务主管',\n",
       " '业务跟单',\n",
       " '福利待遇',\n",
       " '呼叫中心',\n",
       " '汽车销售',\n",
       " '字',\n",
       " '采购主管',\n",
       " '审计',\n",
       " '淘宝运营',\n",
       " '董事长',\n",
       " '市场销售',\n",
       " '组长',\n",
       " '燃油',\n",
       " '国内外',\n",
       " '不是',\n",
       " '适应',\n",
       " '营运',\n",
       " '八千',\n",
       " '多',\n",
       " '房',\n",
       " '工艺工程师',\n",
       " '转',\n",
       " '五',\n",
       " '特约',\n",
       " 'seo',\n",
       " '生活',\n",
       " '长期',\n",
       " '设备工程师',\n",
       " '客服经理',\n",
       " '实训生',\n",
       " '部长',\n",
       " '制',\n",
       " '编制',\n",
       " '苏州',\n",
       " '成本会计',\n",
       " '赴',\n",
       " '教练',\n",
       " '大数据',\n",
       " 'php开发',\n",
       " '驾驶员',\n",
       " '机',\n",
       " '可以',\n",
       " '山东',\n",
       " '南京',\n",
       " '语文',\n",
       " '推广经理',\n",
       " '木工',\n",
       " '手工',\n",
       " 'sem',\n",
       " 'c',\n",
       " '宿',\n",
       " '我家',\n",
       " '律师',\n",
       " '包吃包住',\n",
       " '新房',\n",
       " '客服助理',\n",
       " '机电',\n",
       " '审核员',\n",
       " '起薪',\n",
       " '一对一',\n",
       " '安卓',\n",
       " '仓管员',\n",
       " '为',\n",
       " '国际贸易',\n",
       " '钳工',\n",
       " '整理',\n",
       " '导购员',\n",
       " '名企',\n",
       " '车间',\n",
       " '导',\n",
       " '江苏',\n",
       " '营业部',\n",
       " '薪酬',\n",
       " '统计',\n",
       " '数学教师',\n",
       " '天津',\n",
       " '美术',\n",
       " '幼儿园',\n",
       " '者',\n",
       " '网站编辑',\n",
       " 'ktv',\n",
       " '电子厂',\n",
       " 'web',\n",
       " '不限能',\n",
       " '补',\n",
       " '外贸跟单',\n",
       " '坐席',\n",
       " '医院',\n",
       " '终端',\n",
       " '演艺人',\n",
       " '网站',\n",
       " '有限公司',\n",
       " '留学',\n",
       " '海',\n",
       " '预算',\n",
       " '机会',\n",
       " '普惠',\n",
       " '当',\n",
       " '管',\n",
       " '企划',\n",
       " '运营主管',\n",
       " '电脑',\n",
       " '办事处',\n",
       " '万元',\n",
       " '安全',\n",
       " '外贸助理',\n",
       " '初高中',\n",
       " '机械设计',\n",
       " '即可',\n",
       " '电子工程师',\n",
       " '休息',\n",
       " '分析',\n",
       " '统计员',\n",
       " '工作餐',\n",
       " '四川',\n",
       " '招聘主管',\n",
       " '见习',\n",
       " '网销',\n",
       " 'ebay',\n",
       " '虚拟现实',\n",
       " '上岗',\n",
       " '电焊',\n",
       " '物料',\n",
       " '招聘经理',\n",
       " '活动执行',\n",
       " '电子商务专员',\n",
       " '操作员',\n",
       " '就业',\n",
       " '专家',\n",
       " '10w',\n",
       " '税务专员',\n",
       " '新能源',\n",
       " '游',\n",
       " '央企直',\n",
       " '武汉',\n",
       " '材料',\n",
       " '货船',\n",
       " 'pos',\n",
       " '机场',\n",
       " '医药销售代表',\n",
       " '保险代理',\n",
       " 'ka',\n",
       " '9k',\n",
       " '数控',\n",
       " 'java软件工程师',\n",
       " '机构',\n",
       " '多一份',\n",
       " '收银',\n",
       " '微胖',\n",
       " '业务精英',\n",
       " '医疗器械销售',\n",
       " '海乘',\n",
       " '项目管理',\n",
       " '百万',\n",
       " '保洁',\n",
       " '编程',\n",
       " '家',\n",
       " '起步',\n",
       " '供',\n",
       " '7k',\n",
       " '成',\n",
       " '高福利',\n",
       " '网络营销',\n",
       " '对',\n",
       " 'qa',\n",
       " '二手房',\n",
       " '跨境',\n",
       " '外发',\n",
       " '售后工程师',\n",
       " '检验员',\n",
       " '想',\n",
       " ...]"
      ]
     },
     "execution_count": 40,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "vocab_word"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "# 职位过滤_过滤掉word2vec中没有的职位\n",
    "# positions = [line.strip() for line in open(\"./positions/positions.txt\", 'r', encoding='utf-8').readlines()]\n",
    "\n",
    "# with open(\"./positions/positions_filtered.txt\", \"w\", encoding=\"utf-8\") as fout:\n",
    "#     filtered_count = 0\n",
    "#     for position in positions:\n",
    "#         if(position in vocab_word ):\n",
    "#             fout.write(position)\n",
    "#             fout.write(\"\\n\")\n",
    "#         else:\n",
    "#             filtered_count += 1\n",
    "#             print(position)\n",
    "#     print(filtered_count)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "index2word = {}\n",
    "positions = [line.encode('utf-8').decode('utf-8-sig').strip() for line in open(\"./positions/positions0928.txt\", 'r', encoding='utf-8')]\n",
    "for i in range(len(positions)):\n",
    "    index2word[i] = positions[i]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['销售支持',\n",
       " '渲染师',\n",
       " '党务',\n",
       " '撰稿人',\n",
       " '销售业务跟单',\n",
       " '飞控',\n",
       " '系主任',\n",
       " '董事长',\n",
       " 'ui',\n",
       " '课程顾问',\n",
       " '放映员',\n",
       " 'hse',\n",
       " '淘宝模特',\n",
       " '物流配送',\n",
       " '医师',\n",
       " '网络游戏',\n",
       " '信息员',\n",
       " '化妆',\n",
       " '礼仪员',\n",
       " '爬虫',\n",
       " 'spa',\n",
       " '儿科医生',\n",
       " '康复师',\n",
       " '审查',\n",
       " '杂工',\n",
       " '跟车',\n",
       " '花艺师',\n",
       " '分管',\n",
       " '速卖通',\n",
       " '收货',\n",
       " '食品加工',\n",
       " 'erp技术',\n",
       " '装潢',\n",
       " '测试经理',\n",
       " '队长',\n",
       " '园林绿化',\n",
       " '控员',\n",
       " '项目员',\n",
       " '保养员',\n",
       " '翻译',\n",
       " '配音',\n",
       " '建筑设计师',\n",
       " '代理员',\n",
       " '财务人员',\n",
       " '医疗器械维修',\n",
       " '礼仪',\n",
       " '售票',\n",
       " '钻工',\n",
       " '运维工程师',\n",
       " '电器维修',\n",
       " '打版师',\n",
       " '程序员',\n",
       " '宣传员',\n",
       " 'mysql',\n",
       " '财务管理',\n",
       " '给排水',\n",
       " '大客户经理',\n",
       " '拓展助理',\n",
       " '播音主持',\n",
       " '礼服师',\n",
       " '销售员',\n",
       " '纸样师',\n",
       " '操作师',\n",
       " '饮品师',\n",
       " '报价员',\n",
       " '手机游戏',\n",
       " '置业顾问',\n",
       " '速递员',\n",
       " '配料员',\n",
       " '自动控制',\n",
       " '服务生',\n",
       " '艺人',\n",
       " '包装师',\n",
       " '喷漆技师',\n",
       " '网络编辑',\n",
       " '汽车销售顾问',\n",
       " '日语翻译',\n",
       " '监控员',\n",
       " '场务',\n",
       " '务员',\n",
       " '车床工',\n",
       " '饲养员',\n",
       " '技术开发',\n",
       " 'cocos2dx',\n",
       " '品牌设计',\n",
       " '法务助理',\n",
       " '测量师',\n",
       " '记者',\n",
       " '内勤人员',\n",
       " '管师',\n",
       " '采购经理',\n",
       " '室内装饰',\n",
       " '公关',\n",
       " '餐饮管理',\n",
       " '机械设计',\n",
       " '站务',\n",
       " '电话销售',\n",
       " '区域代理',\n",
       " '业务助理',\n",
       " '理财服务',\n",
       " '数字电路',\n",
       " 'c++',\n",
       " '土木工程',\n",
       " '艺术家',\n",
       " '临床数据分析',\n",
       " '护士',\n",
       " '宿管',\n",
       " '高中教师',\n",
       " '销售管培生',\n",
       " '热控',\n",
       " '勘察',\n",
       " '主厨',\n",
       " '法律顾问',\n",
       " 'windows',\n",
       " '铲车',\n",
       " '道具师',\n",
       " '物流内勤',\n",
       " '网站运营',\n",
       " '创业者',\n",
       " '餐饮服务',\n",
       " '磨床工',\n",
       " '保镖',\n",
       " '跟单文员',\n",
       " '高级技工',\n",
       " '主任医师',\n",
       " '歌手',\n",
       " '空乘',\n",
       " '小时工',\n",
       " '职业顾问',\n",
       " '审核员',\n",
       " '并购',\n",
       " '快递员',\n",
       " '儿童服装',\n",
       " '内科医生',\n",
       " '送餐员',\n",
       " 'erp实施顾问',\n",
       " '厨师长',\n",
       " '钣金工',\n",
       " '数据仓库',\n",
       " '审计',\n",
       " '设计管理',\n",
       " '工程员',\n",
       " '土建',\n",
       " '大堂经理',\n",
       " '女模特',\n",
       " '副主编',\n",
       " '物流送货',\n",
       " '录入',\n",
       " '装配工',\n",
       " '理算',\n",
       " '装修工程',\n",
       " '营销师',\n",
       " '整形外科',\n",
       " '学管',\n",
       " '成本员',\n",
       " '摄影师',\n",
       " '全科医生',\n",
       " '网络营销经理',\n",
       " '采编',\n",
       " '演员',\n",
       " '商务司机',\n",
       " '发行员',\n",
       " '飞行员',\n",
       " '总编辑',\n",
       " '团购业务员',\n",
       " '物理教师',\n",
       " '法务',\n",
       " '分析测试',\n",
       " '加工师',\n",
       " 'andriod',\n",
       " '审批',\n",
       " '注册工程',\n",
       " '配方师',\n",
       " '受理员',\n",
       " '车身设计',\n",
       " '产品策划',\n",
       " '仓管',\n",
       " '保洁',\n",
       " '体系工程师',\n",
       " '创意总监',\n",
       " '出差员',\n",
       " '总账会计',\n",
       " '军训教官',\n",
       " 'dsp',\n",
       " '销管',\n",
       " '设备主管',\n",
       " '教研',\n",
       " '系统分析员',\n",
       " '前厅接待',\n",
       " '电话营销员',\n",
       " '投资顾问',\n",
       " '化学教师',\n",
       " '设备员',\n",
       " '水工',\n",
       " '服务工程师',\n",
       " '木工',\n",
       " '体育老师',\n",
       " '品检',\n",
       " 'cnc编程',\n",
       " '生产员',\n",
       " '面包师',\n",
       " '吊车',\n",
       " '游戏',\n",
       " '地质勘查',\n",
       " '朝鲜语翻译',\n",
       " '代言人',\n",
       " '水电工',\n",
       " '网店店长',\n",
       " 'plm',\n",
       " '网页设计',\n",
       " '营销专员',\n",
       " '微信代理',\n",
       " '安全经理',\n",
       " '验收员',\n",
       " 'seo',\n",
       " '机械工',\n",
       " '房屋中介',\n",
       " '内训师',\n",
       " '能源技术',\n",
       " '商管',\n",
       " '冲床工',\n",
       " '修图师',\n",
       " '机械研发',\n",
       " '特勤',\n",
       " '主持',\n",
       " '原画师',\n",
       " '网络管理',\n",
       " 'net',\n",
       " 'delphi',\n",
       " '核算员',\n",
       " '服装销售',\n",
       " '经理人',\n",
       " '人事管理',\n",
       " '仓库员',\n",
       " '校对员',\n",
       " '测控',\n",
       " '记账',\n",
       " '房地产开发',\n",
       " '总厨',\n",
       " '电子商务总监',\n",
       " '行李员',\n",
       " '烘焙',\n",
       " '汽车定损',\n",
       " '嵌入式软件',\n",
       " '室内装潢',\n",
       " '工程技术',\n",
       " '化验员',\n",
       " '储备经理人',\n",
       " '验货员',\n",
       " '主持人',\n",
       " '事务',\n",
       " '系统工程',\n",
       " '保姆',\n",
       " '广告文案',\n",
       " '仓管员',\n",
       " '软件程序',\n",
       " '下料工',\n",
       " '导师',\n",
       " '销售运营专员',\n",
       " '生物化学',\n",
       " '电脑硬件',\n",
       " '合伙人',\n",
       " '手游',\n",
       " '英文翻译',\n",
       " '申报员',\n",
       " '管员',\n",
       " '建筑施工',\n",
       " '维保员',\n",
       " '配音员',\n",
       " '结构设计',\n",
       " '运营经理',\n",
       " '洗车',\n",
       " '海运操作',\n",
       " '美容美发',\n",
       " '机电工程师',\n",
       " '钻井',\n",
       " '计划员',\n",
       " '事业部管理',\n",
       " '教练',\n",
       " '瓦工',\n",
       " '审计主管',\n",
       " '运行员',\n",
       " '造价员',\n",
       " '市场营销',\n",
       " '虚拟现实',\n",
       " '售货员',\n",
       " '3d设计',\n",
       " '音视频',\n",
       " '药品生产',\n",
       " '后端工程师',\n",
       " '厂务',\n",
       " '施工队',\n",
       " '运营总监',\n",
       " '保险代理',\n",
       " '美术编辑',\n",
       " '总体设计',\n",
       " '审核',\n",
       " '样板师',\n",
       " '设备工程师',\n",
       " '土木建筑',\n",
       " '幼儿教师',\n",
       " '推广业务员',\n",
       " '品酒师',\n",
       " '网店客服',\n",
       " '动漫设计',\n",
       " '巡检员',\n",
       " '客服经理',\n",
       " '收银员',\n",
       " '安装工人',\n",
       " '考务',\n",
       " '园林工程',\n",
       " '镀膜',\n",
       " '生产主管',\n",
       " '销售管理',\n",
       " '录单',\n",
       " '渠道员',\n",
       " '社会工作者',\n",
       " '代账',\n",
       " '招商助理',\n",
       " '交易员',\n",
       " '股票软件',\n",
       " '联络官',\n",
       " '构架师',\n",
       " '手机体验师',\n",
       " '硬件工程师',\n",
       " '报关员',\n",
       " '机工',\n",
       " '安保员',\n",
       " '暖通工程师',\n",
       " '模型师',\n",
       " '麻醉师',\n",
       " '拓展专员',\n",
       " '房地产销售',\n",
       " 'ktv',\n",
       " '签证员',\n",
       " '跟车送货',\n",
       " '理单员',\n",
       " '总装工程师',\n",
       " '装订',\n",
       " '访员',\n",
       " '造价师',\n",
       " '架构',\n",
       " '代驾',\n",
       " '力工',\n",
       " '指导',\n",
       " 'h5',\n",
       " '测评',\n",
       " '管理人员',\n",
       " '咨询顾问',\n",
       " '运营商',\n",
       " '决算员',\n",
       " '后勤保障',\n",
       " '幼师',\n",
       " '派发员',\n",
       " '铣工',\n",
       " 'erlang',\n",
       " '人力资源主管',\n",
       " '调色师',\n",
       " '运输经理',\n",
       " '网站运营总监',\n",
       " 'python',\n",
       " '效果图设计师',\n",
       " '维修师',\n",
       " '管家',\n",
       " '体验师',\n",
       " '排版设计',\n",
       " '舞蹈演员',\n",
       " '化妆品导购',\n",
       " '工艺工程师',\n",
       " '化工研发',\n",
       " '装修装潢设计',\n",
       " '招采',\n",
       " '统筹师',\n",
       " '动力工程',\n",
       " '招聘顾问',\n",
       " '生产工艺',\n",
       " '文字编辑',\n",
       " '语文教师',\n",
       " '制片',\n",
       " '质量检查',\n",
       " '市场总监',\n",
       " '医助',\n",
       " '前台文员',\n",
       " 'php程序',\n",
       " '客服专员',\n",
       " '登记员',\n",
       " '驻店',\n",
       " '园长',\n",
       " '结构师',\n",
       " '渠道专员',\n",
       " '二手车评估师',\n",
       " '福利专员',\n",
       " '会务专员',\n",
       " '系统分析',\n",
       " '市场合伙人',\n",
       " '产品设计',\n",
       " 'java',\n",
       " '磨工',\n",
       " '录音师',\n",
       " '场景师',\n",
       " '设备经理',\n",
       " '货员',\n",
       " '裱花师',\n",
       " '游戏界面设计',\n",
       " '水吧员',\n",
       " '验货',\n",
       " '业务精英',\n",
       " '工人',\n",
       " '设计助理',\n",
       " '物流主管',\n",
       " '引导员',\n",
       " '商标代理',\n",
       " '视觉设计',\n",
       " '安防员',\n",
       " '影视策划',\n",
       " '行政助理',\n",
       " '回访专员',\n",
       " '摄影',\n",
       " '监护',\n",
       " '空姐',\n",
       " '法医',\n",
       " '日审',\n",
       " '画师',\n",
       " 'helpdesk',\n",
       " '规划师',\n",
       " '开发师',\n",
       " '蛋糕师',\n",
       " '星探',\n",
       " 'oa',\n",
       " '维护经理',\n",
       " '主编',\n",
       " '机械结构',\n",
       " '无线通信',\n",
       " '调测',\n",
       " '起重工',\n",
       " '安全员',\n",
       " '收银',\n",
       " '秩序员',\n",
       " '人事经理',\n",
       " '分销代表',\n",
       " '实验员',\n",
       " '系统软件',\n",
       " '代理人',\n",
       " '营销顾问',\n",
       " '保险师',\n",
       " '假期工',\n",
       " '信息技术经理',\n",
       " '关务',\n",
       " '艺术设计',\n",
       " '临床医学',\n",
       " '缝纫工',\n",
       " '汽车装饰美容',\n",
       " '内容运营',\n",
       " '物流专员',\n",
       " '机器学习',\n",
       " '淘宝客服',\n",
       " 'vb',\n",
       " '机械制造',\n",
       " '学徒工',\n",
       " '分销员',\n",
       " '英语老师',\n",
       " '外科',\n",
       " '网络营销',\n",
       " '海乘',\n",
       " '操作员',\n",
       " '软件测试工程',\n",
       " '电话访问员',\n",
       " '店长',\n",
       " '建设工程',\n",
       " '京东客服',\n",
       " '心理医生',\n",
       " '人事主管',\n",
       " '暖通空调工',\n",
       " '服饰',\n",
       " '电脑操作',\n",
       " '薪酬福利主管',\n",
       " 'ka',\n",
       " '外贸助理',\n",
       " '机械设备维护',\n",
       " '早教师',\n",
       " '打包工',\n",
       " '空调工程',\n",
       " '家居设计',\n",
       " '评价师',\n",
       " '客服助理',\n",
       " '教育产品开发',\n",
       " '优化师',\n",
       " '渠道销售',\n",
       " '证券经纪人',\n",
       " '模具工程师',\n",
       " '室内设计',\n",
       " '营销助理',\n",
       " '体验员',\n",
       " '稽核',\n",
       " 'webgis',\n",
       " '司仪',\n",
       " '代课老师',\n",
       " '渠道商',\n",
       " '盘点员',\n",
       " '涉外',\n",
       " '医药销售代表',\n",
       " '女服务员',\n",
       " '人资',\n",
       " '招聘专员',\n",
       " '联络员',\n",
       " '儿童英语',\n",
       " '酒水员',\n",
       " '网商',\n",
       " '保洁工',\n",
       " '外教',\n",
       " '中级会计',\n",
       " '系统工程师',\n",
       " '车间主任',\n",
       " '打样员',\n",
       " '环保员',\n",
       " '公关总监',\n",
       " '品牌专员',\n",
       " '热设计',\n",
       " '资料员',\n",
       " '维护工程师',\n",
       " '运维工',\n",
       " '审计助理',\n",
       " '大使',\n",
       " '图像识别',\n",
       " '门卫',\n",
       " '接待员',\n",
       " '值班人员',\n",
       " '技工',\n",
       " '游泳师',\n",
       " '策划编辑',\n",
       " '事务管理',\n",
       " '网络营销策划',\n",
       " '催乳师',\n",
       " '手机软件',\n",
       " '海员',\n",
       " '接待',\n",
       " '会计证',\n",
       " 'layout',\n",
       " '数控车工',\n",
       " '凉菜师',\n",
       " '塔吊',\n",
       " '物业经理',\n",
       " '包装',\n",
       " '营销员',\n",
       " '前端',\n",
       " '厨工',\n",
       " '采购总监',\n",
       " '检测师',\n",
       " '汽车维修',\n",
       " '销售工程师',\n",
       " '广告文案策划',\n",
       " '评估员',\n",
       " '顾问',\n",
       " '调试员',\n",
       " '音响师',\n",
       " '调研员',\n",
       " '服装',\n",
       " '调度员',\n",
       " '数据库管理员',\n",
       " '电子电器',\n",
       " '分子生物',\n",
       " '景观规划',\n",
       " '办事员',\n",
       " '育种',\n",
       " '发型师',\n",
       " '接单员',\n",
       " '稽查员',\n",
       " '职员',\n",
       " '公关经理',\n",
       " '研究人员',\n",
       " '铸造工',\n",
       " '修图',\n",
       " '财务助理',\n",
       " '电子商务美工',\n",
       " '试车员',\n",
       " '工控',\n",
       " '林业技术人员',\n",
       " '医护',\n",
       " '药师',\n",
       " '工业设计',\n",
       " '主播',\n",
       " '农业机械',\n",
       " '服务器端',\n",
       " '服务端',\n",
       " '测试',\n",
       " '展览设计',\n",
       " 'pb',\n",
       " '建筑制图',\n",
       " '代理商',\n",
       " '律师助理',\n",
       " '业务拓展专员',\n",
       " '拍卖师',\n",
       " '导购员',\n",
       " '测绘',\n",
       " '商务专员',\n",
       " '装饰工',\n",
       " '咨询员',\n",
       " '运动教练',\n",
       " '洗碗工',\n",
       " '淘宝运营',\n",
       " '电焊',\n",
       " '核员',\n",
       " '企业家',\n",
       " '视频剪辑',\n",
       " 'html5',\n",
       " '电子商务经理',\n",
       " '打样师',\n",
       " '律师',\n",
       " '方案设计',\n",
       " '氩弧焊工',\n",
       " '切配',\n",
       " '钳工',\n",
       " '产品销售',\n",
       " '技术工',\n",
       " '人力资源助理',\n",
       " '陶艺',\n",
       " '营销主管',\n",
       " '投资理财',\n",
       " '快递分拣员',\n",
       " '采购专员',\n",
       " '房产经纪人',\n",
       " '护工',\n",
       " '店助',\n",
       " '就业指导',\n",
       " '供应链管理',\n",
       " '售后客服',\n",
       " 'mes',\n",
       " '文控',\n",
       " '外观设计',\n",
       " '后勤人员',\n",
       " '电话营销',\n",
       " '网店运营',\n",
       " '网络管理员',\n",
       " '园林施工',\n",
       " '电话销售代表',\n",
       " '技术主管',\n",
       " '直销经理',\n",
       " '机务',\n",
       " '吧员',\n",
       " '泥水工',\n",
       " '产品代理',\n",
       " '.net',\n",
       " '口译',\n",
       " '熟练工',\n",
       " '跟组',\n",
       " '安检',\n",
       " '外推',\n",
       " '护理员',\n",
       " '徒工',\n",
       " '铣床工',\n",
       " '营销代表',\n",
       " '分拣员',\n",
       " '多媒体设计师',\n",
       " 't台',\n",
       " '编程人员',\n",
       " 'asp.net',\n",
       " '英语教师',\n",
       " '审单员',\n",
       " '灯光设计',\n",
       " '业务主管',\n",
       " '汽车修理工',\n",
       " '安全工程师',\n",
       " '特效师',\n",
       " '投资经理',\n",
       " '小学老师',\n",
       " '翻译师',\n",
       " '结算员',\n",
       " 'ai',\n",
       " '演艺人',\n",
       " '会计师',\n",
       " '工务',\n",
       " '仓库管理',\n",
       " '造价工程师',\n",
       " '物控',\n",
       " '办公室文员',\n",
       " '网络销售',\n",
       " '选址员',\n",
       " '分析员',\n",
       " '特效设计',\n",
       " '天猫美工',\n",
       " '监测员',\n",
       " '机械系统',\n",
       " '人工智能',\n",
       " '音效师',\n",
       " '银行行长',\n",
       " '管理师',\n",
       " '接线工',\n",
       " '体育教师',\n",
       " '金融产品经理',\n",
       " '管培生',\n",
       " '辅导教师',\n",
       " '清洁工',\n",
       " '运营副总经理',\n",
       " '管理人',\n",
       " '谈判',\n",
       " '接电话',\n",
       " '普工',\n",
       " '写手',\n",
       " '企管',\n",
       " '电气控制',\n",
       " '手游主',\n",
       " '维修服务',\n",
       " '旅游产品销售',\n",
       " '会计文员',\n",
       " '注塑工',\n",
       " '报检员',\n",
       " '总务',\n",
       " '水利工程',\n",
       " '技术师',\n",
       " '饲料原料',\n",
       " '推广代表',\n",
       " '电销团',\n",
       " '速录',\n",
       " '推广助理',\n",
       " 'it',\n",
       " 'adas',\n",
       " '排版员',\n",
       " '通勤',\n",
       " '包装设计',\n",
       " '课长',\n",
       " '卖场经理',\n",
       " '服务器',\n",
       " '财务规划师',\n",
       " '政府事务管理',\n",
       " '美容店长',\n",
       " '策划助理',\n",
       " '技术人员',\n",
       " '理货员',\n",
       " '教管',\n",
       " '软件系统',\n",
       " '活动执行',\n",
       " '计算机网络',\n",
       " '促销员',\n",
       " '土建工程师',\n",
       " '美术师',\n",
       " '风控师',\n",
       " '打包员',\n",
       " '加盟商',\n",
       " '城市规划与设计',\n",
       " '销售行政',\n",
       " '游戏软件',\n",
       " '互联网软件',\n",
       " '首席运营官',\n",
       " '婴儿',\n",
       " '网络与信息安全',\n",
       " '现金会计',\n",
       " '后勤',\n",
       " '操作工',\n",
       " 'flash',\n",
       " '行政',\n",
       " '服装设计',\n",
       " '机械加工',\n",
       " '网页设计师',\n",
       " '档案管理',\n",
       " '技术储备',\n",
       " '物业管理',\n",
       " '机械师',\n",
       " '网店运营专员',\n",
       " '分销专员',\n",
       " '翻样员',\n",
       " '柜员',\n",
       " '跟模',\n",
       " '打包',\n",
       " '录入员',\n",
       " '现场应用工程师',\n",
       " 'bi',\n",
       " '商务员',\n",
       " '项目助理',\n",
       " '资金管理',\n",
       " '医生',\n",
       " '采样员',\n",
       " '可靠性',\n",
       " '细胞培养',\n",
       " '副经理',\n",
       " '美工设计',\n",
       " '保安人员',\n",
       " '监查员',\n",
       " '考核员',\n",
       " '会务',\n",
       " 'lua',\n",
       " '业务员',\n",
       " '3dmax',\n",
       " '招聘总监',\n",
       " '软件架构',\n",
       " '电子设计',\n",
       " '招商专员',\n",
       " 'etl',\n",
       " '打单',\n",
       " '副总监',\n",
       " '会计经理',\n",
       " '医疗器械销售',\n",
       " '测试主管',\n",
       " '包装工',\n",
       " '数学老师',\n",
       " '维护员',\n",
       " '质量员',\n",
       " '天猫推广专员',\n",
       " '手艺人',\n",
       " '前台接待',\n",
       " '推广专员',\n",
       " '保健师',\n",
       " '财务官',\n",
       " '京东店长',\n",
       " '外勤人员',\n",
       " '外贸英语',\n",
       " '书记员',\n",
       " '人事总监',\n",
       " '生产项目经理',\n",
       " '天猫客服',\n",
       " '指导员',\n",
       " '市场营销专员',\n",
       " '副总经理',\n",
       " '电子商务专员',\n",
       " '场务场工',\n",
       " '电器设备',\n",
       " '生产物料管理',\n",
       " '人事助理',\n",
       " '法务专员',\n",
       " '疏导员',\n",
       " '水利水电',\n",
       " '迎宾',\n",
       " '仿真',\n",
       " '制图员',\n",
       " '彩妆',\n",
       " '电气工程师',\n",
       " '制作人员',\n",
       " '营销策划经理',\n",
       " '建模师',\n",
       " '美编',\n",
       " '经济人',\n",
       " '审核师',\n",
       " '副所长',\n",
       " '编导',\n",
       " '试衣',\n",
       " '打字员',\n",
       " '母婴',\n",
       " '能源管理',\n",
       " '中医',\n",
       " '总会计师',\n",
       " '艺师',\n",
       " '策划',\n",
       " '培训主管',\n",
       " '排版',\n",
       " '撰写',\n",
       " '会计助理',\n",
       " '私人',\n",
       " '数据挖掘',\n",
       " '施工队长',\n",
       " '主任',\n",
       " '外拓',\n",
       " 'it项目执行',\n",
       " '发货',\n",
       " '系统管理员',\n",
       " '执行官',\n",
       " '群众演员',\n",
       " '临床研究员',\n",
       " '放线员',\n",
       " '汽车配件',\n",
       " '活动策划',\n",
       " '教学辅导',\n",
       " '网络工程师',\n",
       " '调剂员',\n",
       " '防损员',\n",
       " '副校长',\n",
       " '灯光音响',\n",
       " '数据录入',\n",
       " '数据库',\n",
       " '人力资源专员',\n",
       " '售后服务工程师',\n",
       " 'it技术支持',\n",
       " '电机工程',\n",
       " '后期制作',\n",
       " 'spark',\n",
       " '会展',\n",
       " '合成师',\n",
       " '董事',\n",
       " '研究员',\n",
       " '品牌服装',\n",
       " '副行长',\n",
       " '领班',\n",
       " '控制工程',\n",
       " '修理工',\n",
       " '机修钳工',\n",
       " '信托',\n",
       " '照明设计',\n",
       " '汽修工',\n",
       " '财务分析员',\n",
       " '渠道代理',\n",
       " '开发工程师',\n",
       " '软件技术',\n",
       " '外访',\n",
       " '总助',\n",
       " 'gsm',\n",
       " '城市规划',\n",
       " '机修师',\n",
       " '买手',\n",
       " '商务主管',\n",
       " '护理师',\n",
       " '药品研发',\n",
       " '督查',\n",
       " '嵌入式应用',\n",
       " '用户界面',\n",
       " '带车司机',\n",
       " '医药学术推广',\n",
       " '供应商开发',\n",
       " '运行工',\n",
       " '董秘',\n",
       " '早教',\n",
       " '证券总监',\n",
       " '管道工',\n",
       " '电子商务销售',\n",
       " 'sdk',\n",
       " '班主任',\n",
       " '电竞',\n",
       " '技术咨询',\n",
       " '融资总监',\n",
       " '主治医师',\n",
       " '公务机',\n",
       " '志愿者',\n",
       " '监督员',\n",
       " '俄语翻译',\n",
       " '制单员',\n",
       " '市场经理',\n",
       " '育婴',\n",
       " '品质主管',\n",
       " '服务顾问',\n",
       " '研发员',\n",
       " 'linux',\n",
       " '广告创意',\n",
       " '续保员',\n",
       " '侍酒师',\n",
       " '速递',\n",
       " '焊接员',\n",
       " '稽查',\n",
       " '法务经理',\n",
       " '领队',\n",
       " '软件开发',\n",
       " '兼职教师',\n",
       " '商务拓展经理',\n",
       " '预算师',\n",
       " '嵌入式',\n",
       " '译员',\n",
       " '农产品',\n",
       " '统计员',\n",
       " '钻床工',\n",
       " '工程机械',\n",
       " 'db',\n",
       " '医药代表',\n",
       " '设计师',\n",
       " '项目运营',\n",
       " '工商',\n",
       " '形象设计',\n",
       " '管控',\n",
       " '数控铣工',\n",
       " 'arm',\n",
       " '助教',\n",
       " '专利顾问',\n",
       " '研发师',\n",
       " '收费员',\n",
       " '运营助理',\n",
       " '切割工',\n",
       " '话务员',\n",
       " '督查员',\n",
       " '财务会计',\n",
       " '项目经理',\n",
       " '搬运',\n",
       " '海运',\n",
       " '桥梁工程',\n",
       " '行政专员',\n",
       " '数据运营',\n",
       " '董事会',\n",
       " '微信运营专员',\n",
       " '记账员',\n",
       " '翻译员',\n",
       " 'ic设计',\n",
       " '财会人员',\n",
       " '医药保健',\n",
       " '大学老师',\n",
       " '值班员',\n",
       " '奢侈品销售',\n",
       " '动画设计',\n",
       " '配音演员',\n",
       " '机械制图员',\n",
       " '事务员',\n",
       " '业务管理',\n",
       " '接线员',\n",
       " '销售数据分析',\n",
       " '专柜',\n",
       " '电工',\n",
       " '理财顾问',\n",
       " '推销员',\n",
       " '研发经理',\n",
       " '钢琴教师',\n",
       " '金融师',\n",
       " '工程监理',\n",
       " '领导者',\n",
       " '开发设计',\n",
       " '督导员',\n",
       " '制图',\n",
       " '招商顾问',\n",
       " ...]"
      ]
     },
     "execution_count": 19,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "positions"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "2040"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "len(index2word)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "positions_w2v_list = []\n",
    "for position in positions:\n",
    "    positions_w2v_list.append(wv[position].tolist())"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "2040"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "len(positions_w2v_list)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "import numpy as np\n",
    "X = np.array(positions_w2v_list)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(2040, 150)"
      ]
     },
     "execution_count": 9,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "X.shape"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "# kmeans聚类\n",
    "from sklearn.cluster import KMeans\n",
    "from sklearn.metrics import silhouette_score"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {
    "collapsed": false,
    "scrolled": true
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "0    0.000814409404651\n",
      "1    0.0279129555157\n",
      "2    0.0482516067821\n",
      "3    0.0189211460825\n",
      "4    0.0321339546569\n",
      "5    0.0582627410253\n",
      "6    0.0539943258508\n",
      "7    0.00834308316408\n",
      "8    0.00808160914002\n",
      "9    0.0389886242227\n",
      "10   0.0144835906435\n",
      "11   0.0729669998299\n",
      "12   -0.0193128729359\n",
      "13   0.0238257578015\n",
      "14   0.0422439327628\n",
      "15   0.0598119723302\n",
      "16   0.0773706884978\n",
      "17   0.017279715571\n",
      "18   0.0865122281143\n",
      "19   0.0218117542354\n",
      "20   0.0335597315192\n",
      "21   0.0559010896749\n",
      "22   0.0292224501251\n",
      "23   0.0365337295526\n",
      "24   0.0296282426379\n",
      "25   0.0735306956149\n",
      "26   0.00731967225794\n",
      "27   0.0711314349759\n",
      "28   0.0748502636166\n",
      "29   0.0186101384866\n",
      "30   0.0262472299178\n",
      "31   0.0227153835943\n",
      "32   0.00925174950864\n",
      "33   0.0786233368923\n",
      "34   0.0905351053818\n",
      "35   0.0440658406634\n",
      "36   0.0261471977516\n",
      "37   0.0281957206637\n",
      "38   0.0104262601227\n",
      "39   0.0881946414617\n",
      "40   0.00925718195927\n",
      "41   0.0101575686162\n",
      "42   0.0902337604927\n",
      "43   0.0312540884879\n",
      "44   0.0266617523221\n",
      "45   0.0421268244404\n",
      "46   0.0113761455231\n",
      "47   0.0145986251169\n",
      "48   0.00727568792317\n",
      "49   0.0234474752335\n",
      "50   0.0345129279343\n",
      "51   0.00105452566262\n",
      "52   0.0630166258774\n",
      "53   0.00410888202732\n",
      "54   0.00979165764776\n",
      "55   -0.00247947139368\n",
      "56   0.0782972387779\n",
      "57   0.0047897703567\n",
      "58   0.0431158050028\n",
      "59   0.0895544998063\n",
      "60   0.0397826574431\n",
      "61   0.0924941500323\n",
      "62   0.091898970932\n",
      "63   0.0427795890637\n",
      "64   0.0166631046028\n",
      "65   0.0162627353033\n",
      "66   0.0313129509353\n",
      "67   0.0529632210225\n",
      "68   0.0799246585351\n",
      "69   -0.00166154718752\n",
      "70   0.0356102742462\n",
      "71   0.0945064630894\n",
      "72   0.0332767818005\n",
      "73   0.0495781161889\n",
      "74   0.0407559085721\n",
      "75   0.0238282553971\n",
      "76   0.0482390059748\n",
      "77   0.0361259772671\n",
      "78   0.0900907037471\n",
      "79   0.0358757826414\n",
      "80   0.0350449168092\n",
      "81   0.0394450569158\n",
      "82   0.0176652719296\n",
      "83   0.064397926451\n",
      "84   0.0662893112565\n",
      "85   0.0123172915441\n",
      "86   0.0904250367696\n",
      "87   0.00659624153863\n",
      "88   0.033959669305\n",
      "89   0.00706285149979\n",
      "90   0.00693799506672\n",
      "91   0.101613064598\n",
      "92   0.0590715541959\n",
      "93   0.0178841500357\n",
      "94   0.0448885333264\n",
      "95   0.0423055570463\n",
      "96   0.0105844481854\n",
      "97   0.0859630591161\n",
      "98   0.0908887565619\n",
      "99   0.0135189777406\n",
      "100  0.0164592446618\n",
      "101  0.0463155387083\n",
      "102  0.0121976855209\n",
      "103  0.0124957363627\n",
      "104  0.0705643708003\n",
      "105  0.0148531231241\n",
      "106  0.0354689420795\n",
      "107  0.0845661225104\n",
      "108  0.0277747501018\n",
      "109  0.0873127315718\n",
      "110  0.0673085259276\n",
      "111  0.024066253062\n",
      "112  0.0230677535627\n",
      "113  0.0912635943539\n",
      "114  0.0809526203865\n",
      "115  0.0935106308987\n",
      "116  0.0177251348579\n",
      "117  -0.00141869132334\n",
      "118  0.0379934349264\n",
      "119  0.0332249985487\n",
      "120  0.0675194153281\n",
      "121  0.0260494067056\n",
      "122  0.0242574802567\n",
      "123  0.0721457047138\n",
      "124  0.046204820744\n",
      "125  0.073415611761\n",
      "126  0.0201838119085\n",
      "127  0.076003805759\n",
      "128  0.0600543153074\n",
      "129  0.0877639666526\n",
      "130  0.00782684524245\n",
      "131  0.003120473753\n",
      "132  0.0681097874552\n",
      "133  0.0382319589547\n",
      "134  0.019880563413\n",
      "135  0.0584547034162\n",
      "136  0.00242235173058\n",
      "137  0.10572778275\n",
      "138  0.0380006558733\n",
      "139  0.0162593958231\n",
      "140  0.038105599755\n",
      "141  0.0348389241474\n",
      "142  0.0177592582158\n",
      "143  0.0107747094503\n",
      "144  0.0200048002985\n",
      "145  0.0261082452849\n",
      "146  0.100345520846\n",
      "147  0.0931431582189\n",
      "148  0.0536075867298\n",
      "149  0.000192463730791\n",
      "150  0.0203983027481\n",
      "151  0.0256777202813\n",
      "152  0.0159305271004\n",
      "153  0.0465819935182\n",
      "154  0.0704329685913\n",
      "155  0.0213509451013\n",
      "156  0.029032843482\n",
      "157  0.0247413910981\n",
      "158  0.0919959925161\n",
      "159  0.0112612384795\n",
      "160  0.0659335797426\n",
      "161  0.107362841245\n",
      "162  0.0405996206628\n",
      "163  0.0414276149589\n",
      "164  0.07956750994\n",
      "165  0.0882141925996\n",
      "166  0.0323376835316\n",
      "167  0.0326763747458\n",
      "168  0.0308091999744\n",
      "169  0.0909250593336\n",
      "170  0.11198817203\n",
      "171  0.092057079527\n",
      "172  0.0983419823631\n",
      "173  0.0121487559111\n",
      "174  0.0230110521901\n",
      "175  0.0755501547256\n",
      "176  0.0238383331226\n",
      "177  0.0863083910085\n",
      "178  0.0284713492153\n",
      "179  0.100629176667\n",
      "180  0.0642295538566\n",
      "181  0.0520146346008\n",
      "182  0.0391332573429\n",
      "183  -0.0026701308039\n",
      "184  0.0135665003354\n",
      "185  0.0870657242707\n",
      "186  0.0299474093872\n",
      "187  0.0963775552435\n",
      "188  0.00882924588291\n",
      "189  0.0265491380232\n",
      "190  0.013745010132\n",
      "191  0.0866892762274\n",
      "192  0.00458634804639\n",
      "193  0.0246433464655\n",
      "194  -0.00717008275189\n",
      "195  0.108999861308\n",
      "196  0.0687735113524\n",
      "197  0.0212310940608\n",
      "198  0.0370872715434\n",
      "199  0.0546492921661\n",
      "200  0.039882865959\n",
      "201  0.0183583425354\n",
      "202  0.0457361491\n",
      "203  0.0967890790048\n",
      "204  0.0435792575503\n",
      "205  0.0255016435379\n",
      "206  0.0928146258667\n",
      "207  0.038271410408\n",
      "208  0.0566677440365\n",
      "209  0.100104854867\n",
      "210  0.095062817096\n",
      "211  0.0195850242282\n",
      "212  0.0816804369362\n",
      "213  0.0738870001836\n",
      "214  0.0206288824381\n",
      "215  0.00265689718764\n",
      "216  0.0836874732211\n",
      "217  0.00180151288401\n",
      "218  0.0442501897396\n",
      "219  0.0187897416363\n",
      "220  0.0324977541025\n",
      "221  0.00207919100859\n",
      "222  0.026518196223\n",
      "223  0.0374064366622\n",
      "224  0.000820786548866\n",
      "225  0.00606132082021\n",
      "226  0.0442368695359\n",
      "227  0.0767559921591\n",
      "228  0.00332476729753\n",
      "229  0.0252188892403\n",
      "230  0.0232274044218\n",
      "231  0.0666214848417\n",
      "232  0.0340819940148\n",
      "233  0.013256647926\n",
      "234  0.0358359771302\n",
      "235  0.113231793864\n",
      "236  0.0219737655974\n",
      "237  0.0349947760618\n",
      "238  0.0543478388663\n",
      "239  0.0193668188483\n",
      "240  0.0864673194805\n",
      "241  0.0188219027606\n",
      "242  0.0128227742092\n",
      "243  0.0180206868268\n",
      "244  0.0484238391787\n",
      "245  0.0206168214655\n",
      "246  0.0166013763338\n",
      "247  0.0520016866571\n",
      "248  0.033972418161\n",
      "249  0.0167219200809\n",
      "250  0.0607019094086\n",
      "251  0.012401379006\n",
      "252  0.0240242205332\n",
      "253  0.0405410096329\n",
      "254  0.00396085532268\n",
      "255  0.0274351355172\n",
      "256  0.0649926144506\n",
      "257  0.025106397309\n",
      "258  0.0788216480006\n",
      "259  0.038561039173\n",
      "260  0.0796043147993\n",
      "261  0.0308087161669\n",
      "262  0.0203226151526\n",
      "263  0.0136659051793\n",
      "264  -0.000676313402006\n",
      "265  0.0113700202844\n",
      "266  0.0403456917351\n",
      "267  0.0412218142786\n",
      "268  0.0424753515875\n",
      "269  0.0370439660188\n",
      "270  0.0407341378639\n",
      "271  0.0752053019924\n",
      "272  0.0129831568245\n",
      "273  0.119013796066\n",
      "274  0.00338772157998\n",
      "275  0.0845299579783\n",
      "276  0.0260155650174\n",
      "277  0.0262582079927\n",
      "278  0.076942141098\n",
      "279  0.0509137437795\n",
      "280  0.015260852837\n",
      "281  0.0287110457393\n",
      "282  0.0152860366557\n",
      "283  0.0224405352323\n",
      "284  0.0440425698066\n",
      "285  0.0327838690138\n",
      "286  0.030376543963\n",
      "287  0.0246835870723\n",
      "288  0.0305006535929\n",
      "289  0.0579939558775\n",
      "290  0.0865453388749\n",
      "291  0.0610671242596\n",
      "292  0.0111812790935\n",
      "293  0.0128216244147\n",
      "294  0.0912489932569\n",
      "295  0.0371457610856\n",
      "296  0.0214777970188\n",
      "297  0.0313775571227\n",
      "298  0.0479308341133\n",
      "299  0.0203060072234\n",
      "300  0.0718323471439\n",
      "301  0.0268781595783\n",
      "302  0.0176660556156\n",
      "303  0.0539011495373\n",
      "304  0.0353792688885\n",
      "305  0.0787410818489\n",
      "306  0.0670351587901\n",
      "307  0.0323464040592\n",
      "308  0.0913620227056\n",
      "309  0.0143799499414\n",
      "310  0.0167453453564\n",
      "311  0.0229841530866\n",
      "312  0.0363715042905\n",
      "313  -0.00193568635314\n",
      "314  0.0468125795746\n",
      "315  0.0950979888826\n",
      "316  0.0290434329919\n",
      "317  0.0870412385698\n",
      "318  0.0278861916165\n",
      "319  0.0299267797467\n",
      "320  0.0174858807222\n",
      "321  0.00428773716628\n",
      "322  -0.00225668916829\n",
      "323  0.0130873483722\n",
      "324  0.0225378529199\n",
      "325  0.0213614816369\n",
      "326  0.0328626339357\n",
      "327  0.0507848028833\n",
      "328  0.103491061218\n",
      "329  0.0355487062009\n",
      "330  0.0846623583424\n",
      "331  0.101330543354\n",
      "332  0.0892040267018\n",
      "333  0.0505861333335\n",
      "334  0.0563646166453\n",
      "335  0.0750662534092\n",
      "336  0.0321590070971\n",
      "337  0.0454437966947\n",
      "338  0.00854813871261\n",
      "339  0.0158898283506\n",
      "340  0.0197992833118\n",
      "341  0.0473394292938\n",
      "342  0.00812942203556\n",
      "343  0.0435460299529\n",
      "344  -0.0133656789185\n",
      "345  0.0292131299269\n",
      "346  0.072310026574\n",
      "347  0.00603034235068\n",
      "348  0.0253022017873\n",
      "349  0.0267047945249\n",
      "350  0.0271014261752\n",
      "351  0.0208395190432\n",
      "352  0.0719278688031\n",
      "353  0.0184423013982\n",
      "354  0.0235629376901\n",
      "355  0.00489667632593\n",
      "356  0.023624451327\n",
      "357  0.101808265799\n",
      "358  0.0279426534631\n",
      "359  0.0243561933958\n",
      "360  0.0288385974091\n",
      "361  0.0972477987137\n",
      "362  0.0105834926601\n",
      "363  0.0533878181952\n",
      "364  0.0230016394718\n",
      "365  0.0303640747951\n",
      "366  0.0402197667619\n",
      "367  0.0720665683776\n",
      "368  0.0281954366448\n",
      "369  0.0279342192012\n",
      "370  0.0239720683573\n",
      "371  0.128015181671\n",
      "372  0.0732649752205\n",
      "373  -0.0232834357394\n",
      "374  0.0379245149183\n",
      "375  0.0737693600302\n",
      "376  0.0344299952959\n",
      "377  0.0851403836699\n",
      "378  0.027790452426\n",
      "379  0.0865517313722\n",
      "380  0.0929898051174\n",
      "381  0.0577551334698\n",
      "382  0.0975395040425\n",
      "383  0.00593245554517\n",
      "384  0.0692837425812\n",
      "385  0.0953075030344\n",
      "386  0.0435713370744\n",
      "387  0.0735891960762\n",
      "388  0.0153794735979\n",
      "389  0.0560729234089\n",
      "390  0.0219606559081\n",
      "391  0.0770039329627\n",
      "392  0.116357607423\n",
      "393  0.0315239406477\n",
      "394  0.00863885762437\n",
      "395  0.0416279597137\n",
      "396  0.00415076901327\n",
      "397  0.0732543933935\n",
      "398  0.0267508569226\n",
      "399  0.0564247399673\n",
      "400  0.0357330658073\n",
      "401  0.0640579541761\n",
      "402  0.039857466289\n",
      "403  0.0390913063182\n",
      "404  0.00967606851652\n",
      "405  0.0237901445463\n",
      "406  0.0262573645402\n",
      "407  0.0781274845455\n",
      "408  0.0162976522688\n",
      "409  0.0348889969038\n",
      "410  0.081407027088\n",
      "411  0.0802856222433\n",
      "412  0.0859423418963\n",
      "413  0.0363861681521\n",
      "414  0.0805404294312\n",
      "415  0.0699931733791\n",
      "416  0.0392476818628\n",
      "417  0.00479027282359\n",
      "418  0.0742943447502\n",
      "419  0.0792320498451\n",
      "420  0.0720030117421\n",
      "421  0.00449129842074\n",
      "422  0.0321909074605\n",
      "423  0.0199799377589\n",
      "424  -0.0041987196988\n",
      "425  0.00552020033072\n",
      "426  0.0673425446007\n",
      "427  0.00752562735443\n",
      "428  0.0862305488058\n",
      "429  0.0268817880237\n",
      "430  0.0241822865473\n",
      "431  0.109758783024\n",
      "432  0.0245335146884\n",
      "433  0.0173007465853\n",
      "434  0.0585334614593\n",
      "435  0.0591313836251\n",
      "436  0.0327725491765\n",
      "437  0.079758746919\n",
      "438  0.0656130580901\n",
      "439  0.000528521791463\n",
      "440  0.108492918961\n",
      "441  0.045787416676\n",
      "442  0.0188896052111\n",
      "443  0.0480170895371\n",
      "444  0.0487437428908\n",
      "445  0.0915446140794\n",
      "446  0.069437962032\n",
      "447  0.00837145702064\n",
      "448  0.0982016608078\n",
      "449  0.0636435541798\n",
      "450  0.0242608359372\n",
      "451  0.0400174686726\n",
      "452  0.0405307232241\n",
      "453  0.0227306994675\n",
      "454  0.0127381668876\n",
      "455  0.0116069084763\n",
      "456  0.075900969064\n",
      "457  0.0174721751453\n",
      "458  0.10050495127\n",
      "459  0.0222776458677\n",
      "460  0.0479579664101\n",
      "461  0.0606532785339\n",
      "462  0.0363789568407\n",
      "463  0.0277152971801\n",
      "464  0.0590362730306\n",
      "465  0.0225172592177\n",
      "466  0.0160557505726\n",
      "467  0.0889737568425\n",
      "468  0.00783962504898\n",
      "469  0.0286051055176\n",
      "470  -0.00325445214252\n",
      "471  0.031277537656\n",
      "472  0.0814198696296\n",
      "473  0.0428144384795\n",
      "474  0.0744495200874\n",
      "475  0.0182282879723\n",
      "476  0.0100479268525\n",
      "477  0.0156687272768\n",
      "478  0.0189805763822\n",
      "479  0.025790950399\n",
      "480  0.0863720571427\n",
      "481  0.0401994879634\n",
      "482  0.0392516528798\n",
      "483  0.000910920923341\n",
      "484  0.0261988138122\n",
      "485  0.0239025418613\n",
      "486  0.090941670998\n",
      "487  0.0235267469575\n",
      "488  0.0369466435358\n",
      "489  0.0484216871695\n",
      "490  0.0458263202184\n",
      "491  0.100310576148\n",
      "492  0.00801846301701\n",
      "493  0.0177640962957\n",
      "494  0.0927178260604\n",
      "495  -0.00630437704675\n",
      "496  0.00942675372168\n",
      "497  0.0254411280425\n",
      "498  0.0174109285858\n",
      "499  0.0338726833756\n",
      "500  0.0130322539262\n",
      "501  0.0487162828578\n",
      "502  0.0447563388286\n",
      "503  0.0101466785037\n",
      "504  0.0143562358524\n",
      "505  0.0105549934668\n",
      "506  0.0764395569705\n",
      "507  0.00364601900997\n",
      "508  -0.00103143172111\n",
      "509  0.0229087408781\n",
      "510  0.0634153626518\n",
      "511  0.0250680289936\n",
      "512  0.00532574144065\n",
      "513  0.0121537989466\n",
      "514  0.0167861288001\n",
      "515  0.00489828885978\n",
      "516  0.0795004749862\n",
      "517  0.00679759811474\n",
      "518  0.0245003373427\n",
      "519  0.00506688273323\n",
      "520  0.0415180469614\n",
      "521  -0.0279167860471\n",
      "522  0.0895578678689\n",
      "523  0.0481968452479\n",
      "524  0.0437309917259\n",
      "525  0.0865055471764\n",
      "526  0.00683692043038\n",
      "527  0.0143081495927\n",
      "528  0.00994022319286\n",
      "529  0.0182837020367\n",
      "530  0.0237075584052\n",
      "531  0.0594186873041\n",
      "532  0.0139027040122\n",
      "533  0.0618016579875\n",
      "534  0.0224062011076\n",
      "535  0.0112851206433\n",
      "536  0.0260148945983\n",
      "537  0.0149298004807\n",
      "538  0.00506634246304\n",
      "539  0.0850248013592\n",
      "540  0.00855188850637\n",
      "541  0.0184093992666\n",
      "542  0.0498141680686\n",
      "543  0.0438898707409\n",
      "544  0.022516166195\n",
      "545  0.111832024129\n",
      "546  0.0555895887753\n",
      "547  0.0554915693662\n",
      "548  0.029974946324\n",
      "549  0.0291996021194\n",
      "550  0.0149314225976\n",
      "551  0.0693410401343\n",
      "552  0.0215089527194\n",
      "553  0.0617927301019\n",
      "554  0.0196458611753\n",
      "555  0.0342628106518\n",
      "556  0.039170596284\n",
      "557  0.00895002794759\n",
      "558  0.00548549914938\n",
      "559  0.0832487956318\n",
      "560  0.0312349136941\n",
      "561  0.0857060387612\n",
      "562  0.0151696520511\n",
      "563  0.0335198323694\n",
      "564  0.0250816155468\n",
      "565  0.00138571059211\n",
      "566  0.0549700359246\n",
      "567  0.0643413762464\n",
      "568  0.0190988353687\n",
      "569  0.069869308169\n",
      "570  0.107212563122\n",
      "571  0.0414937559717\n",
      "572  0.0109585738966\n",
      "573  0.0320768674323\n",
      "574  0.00197737628042\n",
      "575  0.0690804872594\n",
      "576  0.0323132403995\n",
      "577  0.0230529704484\n",
      "578  0.0543535343092\n",
      "579  0.0572576995168\n",
      "580  0.0188394974406\n",
      "581  0.0118917550367\n",
      "582  0.0131548900937\n",
      "583  0.0537213604433\n",
      "584  0.0447229951545\n",
      "585  0.0181302700078\n",
      "586  0.0269562678473\n",
      "587  0.0402750205971\n",
      "588  0.00644249369126\n",
      "589  0.114884778284\n",
      "590  0.00933627613651\n",
      "591  0.00482522067667\n",
      "592  0.0225063844463\n",
      "593  0.02959981346\n",
      "594  0.0296936922553\n",
      "595  -0.0057365200338\n",
      "596  0.0406370329431\n",
      "597  0.0200287075162\n",
      "598  0.0191935294628\n",
      "599  0.0916307518857\n",
      "600  0.0927851039139\n",
      "601  0.0199744276593\n",
      "602  0.0748145720918\n",
      "603  0.0874931564179\n",
      "604  0.0109137190939\n",
      "605  0.0870022344983\n",
      "606  0.00281834311584\n",
      "607  0.0378639275538\n",
      "608  0.0838679329788\n",
      "609  0.0802826018783\n",
      "610  0.011705497923\n",
      "611  0.0321198280196\n",
      "612  0.0829540383286\n",
      "613  0.0884902029241\n",
      "614  0.0130754743432\n",
      "615  0.081198183905\n",
      "616  0.00851853569166\n",
      "617  0.0315862148734\n",
      "618  0.000144422528313\n",
      "619  0.0271574745917\n",
      "620  0.0359241020779\n",
      "621  0.0405173627893\n",
      "622  0.0400555607987\n",
      "623  -0.00178232223426\n",
      "624  0.0632441731002\n",
      "625  0.0326713284628\n",
      "626  0.00431828674851\n",
      "627  0.0316978919042\n",
      "628  0.0706244181219\n",
      "629  0.00171081237842\n",
      "630  0.0856690498222\n",
      "631  0.0111395322824\n",
      "632  0.0167435898071\n",
      "633  0.0319932034519\n",
      "634  0.0413339150919\n",
      "635  0.0816074929039\n",
      "636  0.0322996561196\n",
      "637  0.0168885131286\n",
      "638  0.0309825814666\n",
      "639  0.00490120263775\n",
      "640  0.0305233270466\n",
      "641  0.0669586350529\n",
      "642  -0.0124848723133\n",
      "643  0.0975460878915\n",
      "644  0.105940838998\n",
      "645  0.0248297268835\n",
      "646  0.0582180511395\n",
      "647  0.0236978755277\n",
      "648  0.00562594667536\n",
      "649  0.0436038833226\n",
      "650  0.00121531164449\n",
      "651  0.0144102349545\n",
      "652  0.100370044388\n",
      "653  0.0586999650841\n",
      "654  -0.000964728045054\n",
      "655  0.0358098467604\n",
      "656  0.00238755799752\n",
      "657  0.0409727925991\n",
      "658  0.0277630207339\n",
      "659  0.0952592027929\n",
      "660  0.0404731568288\n",
      "661  0.0476061101702\n",
      "662  0.0292510509571\n",
      "663  0.028299975551\n",
      "664  0.0111016160254\n",
      "665  0.0200501704387\n",
      "666  0.0989141143823\n",
      "667  0.0891071326963\n",
      "668  0.0451639685454\n",
      "669  0.0477272983539\n",
      "670  0.021403757429\n",
      "671  0.0640520480409\n",
      "672  0.0421421437202\n",
      "673  0.101161821394\n",
      "674  0.00801000115128\n",
      "675  0.0533290076014\n",
      "676  0.00112176201874\n",
      "677  0.0208521632113\n",
      "678  0.0076847779764\n",
      "679  0.00584185181462\n",
      "680  0.0534571569064\n",
      "681  0.0199576830149\n",
      "682  0.0100844181747\n",
      "683  -0.000740383633718\n",
      "684  0.0145577577083\n",
      "685  -0.000203984170137\n",
      "686  0.0140339599268\n",
      "687  0.009852122415\n",
      "688  0.0929264743757\n",
      "689  0.0835579612924\n",
      "690  0.0628916343206\n",
      "691  0.0322358257555\n",
      "692  0.0375869693262\n",
      "693  0.00980926301133\n",
      "694  0.0464038950303\n",
      "695  0.023661421794\n",
      "696  0.012843286339\n",
      "697  0.00900873735278\n",
      "698  0.0203800455064\n",
      "699  0.0199992347551\n",
      "700  0.0600696677946\n",
      "701  0.0318799313431\n",
      "702  0.0301330265288\n",
      "703  0.0622338722932\n",
      "704  -0.00038237229497\n",
      "705  0.00976673963859\n",
      "706  0.0455240225124\n",
      "707  0.0348901382066\n",
      "708  0.0407017360809\n",
      "709  0.0906230609334\n",
      "710  0.0144960441666\n",
      "711  0.0583015316212\n",
      "712  0.0213520895371\n",
      "713  0.0535853429497\n",
      "714  0.0230919163604\n",
      "715  0.0795624196824\n",
      "716  0.00987691973983\n",
      "717  0.062960972506\n",
      "718  0.0844811988951\n",
      "719  0.0846438764231\n",
      "720  0.0172560284993\n",
      "721  0.0909519290908\n",
      "722  0.0201483219436\n",
      "723  0.00619800318437\n",
      "724  0.0190772027867\n",
      "725  0.0182965908015\n",
      "726  0.0904713771467\n",
      "727  0.0524933272622\n",
      "728  0.0207882253394\n",
      "729  0.0847793262309\n",
      "730  0.0846279872514\n",
      "731  0.0743532502086\n",
      "732  0.0393934282673\n",
      "733  0.0556306256201\n",
      "734  0.044667646306\n",
      "735  0.0361811614028\n",
      "736  0.0246046492378\n",
      "737  0.0756737013832\n",
      "738  0.0609607953926\n",
      "739  0.033374063171\n",
      "740  0.0825688099328\n",
      "741  0.0923550754693\n",
      "742  0.0169973775392\n",
      "743  0.0117182900403\n",
      "744  0.0119887389571\n",
      "745  0.0575225444306\n",
      "746  0.0215697767614\n",
      "747  0.0581848755226\n",
      "748  0.0276546892412\n",
      "749  0.0338746927815\n",
      "750  0.0317208842686\n",
      "751  0.0317324377454\n",
      "752  0.0307902251279\n",
      "753  0.0452575408466\n",
      "754  0.0185964558403\n",
      "755  0.000551895758266\n",
      "756  0.0258489146709\n",
      "757  0.0640493178913\n",
      "758  0.051290478101\n",
      "759  0.0694726635459\n",
      "760  0.0295660847035\n",
      "761  0.0343288966066\n",
      "762  0.0189358147192\n",
      "763  0.0379611364337\n",
      "764  0.0223554921003\n",
      "765  0.0143187486991\n",
      "766  0.000938254574284\n",
      "767  0.0216313139362\n",
      "768  0.0876314590928\n",
      "769  0.0145731079057\n",
      "770  0.0288997715151\n",
      "771  0.0823282373517\n",
      "772  0.0272437420303\n",
      "773  0.0173088487932\n",
      "774  0.00941326979411\n",
      "775  0.0577952081001\n",
      "776  0.0231962470403\n",
      "777  0.00983524403949\n",
      "778  0.0994406647982\n",
      "779  -0.00473258265004\n",
      "780  0.00916066390795\n",
      "781  0.0147915590743\n",
      "782  0.00707461890413\n",
      "783  0.0550999780851\n",
      "784  0.0100379022862\n",
      "785  0.00360348181078\n",
      "786  0.0492014743515\n",
      "787  0.0712639664177\n",
      "788  0.0313433780992\n",
      "789  0.00628046198861\n",
      "790  -0.0211160689367\n",
      "791  0.0942086826494\n",
      "792  0.0647420292367\n",
      "793  0.0598263845602\n",
      "794  0.0829418475192\n",
      "795  0.00825191142203\n",
      "796  0.0571473293175\n",
      "797  0.0245031978142\n",
      "798  0.0808628675996\n",
      "799  0.0256105315614\n",
      "800  0.00323850262938\n",
      "801  0.0841154794841\n",
      "802  0.0822075449098\n",
      "803  0.128245366722\n",
      "804  -0.00402508516595\n",
      "805  0.0657347973761\n",
      "806  0.0628421484829\n",
      "807  0.042115740162\n",
      "808  0.0763800594963\n",
      "809  0.0142158386695\n",
      "810  0.0428660511781\n",
      "811  0.0080293908111\n",
      "812  0.0450823743597\n",
      "813  0.0175268640785\n",
      "814  0.0649157848318\n",
      "815  0.0820548376135\n",
      "816  0.0825313947651\n",
      "817  0.043027537577\n",
      "818  0.0315429993747\n",
      "819  0.0182257072369\n",
      "820  0.0967100603205\n",
      "821  0.0817174248336\n",
      "822  0.00703297117681\n",
      "823  0.0687827920925\n",
      "824  0.00279172698499\n",
      "825  0.0185644055474\n",
      "826  0.0468748354235\n",
      "827  0.0125342753632\n",
      "828  0.0293329669341\n",
      "829  0.0720673430306\n",
      "830  0.0319833596402\n",
      "831  0.0171764157847\n",
      "832  0.105220466358\n",
      "833  0.0398155462474\n",
      "834  0.0687027498118\n",
      "835  0.0381696105388\n",
      "836  0.0676808916533\n",
      "837  0.0834537890577\n",
      "838  0.0541980801949\n",
      "839  0.0260852961675\n",
      "840  0.0652007353419\n",
      "841  0.0654633904128\n",
      "842  0.0138648625923\n",
      "843  0.0178921303536\n",
      "844  0.0319327050845\n",
      "845  0.0780392291553\n",
      "846  0.0584131835595\n",
      "847  0.0331789962308\n",
      "848  0.0575375545811\n",
      "849  0.105292282871\n",
      "850  0.0371103396496\n",
      "851  0.0845159650184\n",
      "852  0.0905514650868\n",
      "853  0.0138198724773\n",
      "854  -0.00386946930362\n",
      "855  0.0909551089004\n",
      "856  0.0848799521184\n",
      "857  0.0687115250466\n",
      "858  0.056440712807\n",
      "859  0.0644373356764\n",
      "860  0.0290470454931\n",
      "861  0.0489071128245\n",
      "862  0.0437331817705\n",
      "863  0.0635696293459\n",
      "864  0.0164311091201\n",
      "865  0.0288079781233\n",
      "866  0.0390173118082\n",
      "867  0.0287006062171\n",
      "868  0.0340136783829\n",
      "869  0.0219447184344\n",
      "870  0.0568121635788\n",
      "871  0.0747275079252\n",
      "872  0.0747686587563\n",
      "873  0.0777567814615\n",
      "874  0.0558038857663\n",
      "875  0.0353297889345\n",
      "876  0.00675975065685\n",
      "877  0.0119410035326\n",
      "878  0.044019601181\n",
      "879  0.0287459588307\n",
      "880  0.00825538907908\n",
      "881  0.0517564253398\n",
      "882  0.0653581671209\n",
      "883  0.0212799033299\n",
      "884  0.0363684435054\n",
      "885  0.0366948402341\n",
      "886  0.0824646539737\n",
      "887  0.0518500731844\n",
      "888  0.0120704189199\n",
      "889  0.034306176115\n",
      "890  0.0729207540618\n",
      "891  0.0798920400409\n",
      "892  0.0855103001909\n",
      "893  0.0478667748361\n",
      "894  0.0173819743683\n",
      "895  0.0227287986026\n",
      "896  0.0952278810293\n",
      "897  0.0782047240624\n",
      "898  0.00202217164153\n",
      "899  0.016250373273\n",
      "900  0.00838201833435\n",
      "901  0.0726472926343\n",
      "902  0.0342271247814\n",
      "903  0.0506499089729\n",
      "904  0.0384915996958\n",
      "905  0.0591790884992\n",
      "906  0.0442591293222\n",
      "907  0.0866854461025\n",
      "908  0.00972320761564\n",
      "909  0.0321928760891\n",
      "910  0.0300029314597\n",
      "911  0.10086893307\n",
      "912  0.0413631796041\n",
      "913  0.0886434479143\n",
      "914  0.0122724412037\n",
      "915  0.0794400435803\n",
      "916  0.0244882183972\n",
      "917  0.0900484507006\n",
      "918  0.0320985025743\n",
      "919  0.0935693551714\n",
      "920  0.00450397766039\n",
      "921  0.0757918295556\n",
      "922  0.021427969251\n",
      "923  0.0681305691901\n",
      "924  0.0486979427979\n",
      "925  0.0646090267033\n",
      "926  0.0449684901856\n",
      "927  0.0262602466776\n",
      "928  0.00791387524125\n",
      "929  0.0241725294945\n",
      "930  0.0198300109621\n",
      "931  0.0435543907501\n",
      "932  0.00601390125263\n",
      "933  0.0825807195795\n",
      "934  0.0515370147471\n",
      "935  0.0179852270847\n",
      "936  0.0844249998331\n",
      "937  0.0525358664111\n",
      "938  0.032061546018\n",
      "939  0.00613877245841\n",
      "940  0.0616018678401\n",
      "941  0.0649791422635\n",
      "942  0.00614035549666\n",
      "943  -0.00272295023228\n",
      "944  0.0896767410514\n",
      "945  0.00345140625069\n",
      "946  0.0866384527166\n",
      "947  0.00534642192474\n",
      "948  0.0818033797373\n",
      "949  0.0852441054043\n",
      "950  0.0603626881368\n",
      "951  0.0217016312773\n",
      "952  0.0637148056227\n",
      "953  0.0474820544122\n",
      "954  0.0131631036925\n",
      "955  0.021662643996\n",
      "956  0.00498572916674\n",
      "957  -0.00480362496713\n",
      "958  0.0876203790834\n",
      "959  0.0153497581665\n",
      "960  0.00381825006375\n",
      "961  0.0347841018377\n",
      "962  0.0487076597409\n",
      "963  0.0135251397624\n"
     ]
    },
    {
     "ename": "KeyboardInterrupt",
     "evalue": "",
     "output_type": "error",
     "traceback": [
      "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[0;31mKeyboardInterrupt\u001b[0m                         Traceback (most recent call last)",
      "\u001b[0;32m<ipython-input-11-c95825eb0f4b>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m()\u001b[0m\n\u001b[1;32m      1\u001b[0m \u001b[1;32mfor\u001b[0m \u001b[0mi\u001b[0m \u001b[1;32min\u001b[0m \u001b[0mrange\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;36m1000\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m----> 2\u001b[0;31m     \u001b[0mkmeans\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mKMeans\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mn_clusters\u001b[0m\u001b[1;33m=\u001b[0m\u001b[1;36m110\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0minit\u001b[0m\u001b[1;33m=\u001b[0m\u001b[1;34m'k-means++'\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mn_init\u001b[0m\u001b[1;33m=\u001b[0m\u001b[1;36m10\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mfit\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mX\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m      3\u001b[0m     \u001b[0mscore\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0msilhouette_score\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mX\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mkmeans\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mlabels_\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m      4\u001b[0m     \u001b[0mprint\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;34m\"%-5s%-10s\"\u001b[0m \u001b[1;33m%\u001b[0m \u001b[1;33m(\u001b[0m\u001b[0mi\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mscore\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m      5\u001b[0m     \u001b[1;32mif\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mscore\u001b[0m \u001b[1;33m>\u001b[0m \u001b[1;36m0.2\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
      "\u001b[0;32mD:\\Anaconda3\\lib\\site-packages\\sklearn\\cluster\\k_means_.py\u001b[0m in \u001b[0;36mfit\u001b[0;34m(self, X, y)\u001b[0m\n\u001b[1;32m    891\u001b[0m                 \u001b[0mtol\u001b[0m\u001b[1;33m=\u001b[0m\u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mtol\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mrandom_state\u001b[0m\u001b[1;33m=\u001b[0m\u001b[0mrandom_state\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mcopy_x\u001b[0m\u001b[1;33m=\u001b[0m\u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mcopy_x\u001b[0m\u001b[1;33m,\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m    892\u001b[0m                 \u001b[0mn_jobs\u001b[0m\u001b[1;33m=\u001b[0m\u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mn_jobs\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0malgorithm\u001b[0m\u001b[1;33m=\u001b[0m\u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0malgorithm\u001b[0m\u001b[1;33m,\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m--> 893\u001b[0;31m                 return_n_iter=True)\n\u001b[0m\u001b[1;32m    894\u001b[0m         \u001b[1;32mreturn\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m    895\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n",
      "\u001b[0;32mD:\\Anaconda3\\lib\\site-packages\\sklearn\\cluster\\k_means_.py\u001b[0m in \u001b[0;36mk_means\u001b[0;34m(X, n_clusters, init, precompute_distances, n_init, max_iter, verbose, tol, random_state, copy_x, n_jobs, algorithm, return_n_iter)\u001b[0m\n\u001b[1;32m    344\u001b[0m                 \u001b[0mX\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mn_clusters\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mmax_iter\u001b[0m\u001b[1;33m=\u001b[0m\u001b[0mmax_iter\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0minit\u001b[0m\u001b[1;33m=\u001b[0m\u001b[0minit\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mverbose\u001b[0m\u001b[1;33m=\u001b[0m\u001b[0mverbose\u001b[0m\u001b[1;33m,\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m    345\u001b[0m                 \u001b[0mprecompute_distances\u001b[0m\u001b[1;33m=\u001b[0m\u001b[0mprecompute_distances\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mtol\u001b[0m\u001b[1;33m=\u001b[0m\u001b[0mtol\u001b[0m\u001b[1;33m,\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m--> 346\u001b[0;31m                 x_squared_norms=x_squared_norms, random_state=random_state)\n\u001b[0m\u001b[1;32m    347\u001b[0m             \u001b[1;31m# determine if these results are the best so far\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m    348\u001b[0m             \u001b[1;32mif\u001b[0m \u001b[0mbest_inertia\u001b[0m \u001b[1;32mis\u001b[0m \u001b[1;32mNone\u001b[0m \u001b[1;32mor\u001b[0m \u001b[0minertia\u001b[0m \u001b[1;33m<\u001b[0m \u001b[0mbest_inertia\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
      "\u001b[0;32mD:\\Anaconda3\\lib\\site-packages\\sklearn\\cluster\\k_means_.py\u001b[0m in \u001b[0;36m_kmeans_single_elkan\u001b[0;34m(X, n_clusters, max_iter, init, verbose, x_squared_norms, random_state, tol, precompute_distances)\u001b[0m\n\u001b[1;32m    393\u001b[0m     \u001b[1;31m# init\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m    394\u001b[0m     centers = _init_centroids(X, n_clusters, init, random_state=random_state,\n\u001b[0;32m--> 395\u001b[0;31m                               x_squared_norms=x_squared_norms)\n\u001b[0m\u001b[1;32m    396\u001b[0m     \u001b[0mcenters\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mnp\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mascontiguousarray\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mcenters\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m    397\u001b[0m     \u001b[1;32mif\u001b[0m \u001b[0mverbose\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
      "\u001b[0;32mD:\\Anaconda3\\lib\\site-packages\\sklearn\\cluster\\k_means_.py\u001b[0m in \u001b[0;36m_init_centroids\u001b[0;34m(X, k, init, random_state, x_squared_norms, init_size)\u001b[0m\n\u001b[1;32m    682\u001b[0m     \u001b[1;32mif\u001b[0m \u001b[0misinstance\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0minit\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mstring_types\u001b[0m\u001b[1;33m)\u001b[0m \u001b[1;32mand\u001b[0m \u001b[0minit\u001b[0m \u001b[1;33m==\u001b[0m \u001b[1;34m'k-means++'\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m    683\u001b[0m         centers = _k_init(X, k, random_state=random_state,\n\u001b[0;32m--> 684\u001b[0;31m                           x_squared_norms=x_squared_norms)\n\u001b[0m\u001b[1;32m    685\u001b[0m     \u001b[1;32melif\u001b[0m \u001b[0misinstance\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0minit\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mstring_types\u001b[0m\u001b[1;33m)\u001b[0m \u001b[1;32mand\u001b[0m \u001b[0minit\u001b[0m \u001b[1;33m==\u001b[0m \u001b[1;34m'random'\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m    686\u001b[0m         \u001b[0mseeds\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mrandom_state\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mpermutation\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mn_samples\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m[\u001b[0m\u001b[1;33m:\u001b[0m\u001b[0mk\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
      "\u001b[0;32mD:\\Anaconda3\\lib\\site-packages\\sklearn\\cluster\\k_means_.py\u001b[0m in \u001b[0;36m_k_init\u001b[0;34m(X, n_clusters, x_squared_norms, random_state, n_local_trials)\u001b[0m\n\u001b[1;32m    106\u001b[0m         \u001b[1;31m# to the squared distance to the closest existing center\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m    107\u001b[0m         \u001b[0mrand_vals\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mrandom_state\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mrandom_sample\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mn_local_trials\u001b[0m\u001b[1;33m)\u001b[0m \u001b[1;33m*\u001b[0m \u001b[0mcurrent_pot\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m--> 108\u001b[0;31m         candidate_ids = np.searchsorted(stable_cumsum(closest_dist_sq),\n\u001b[0m\u001b[1;32m    109\u001b[0m                                         rand_vals)\n\u001b[1;32m    110\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n",
      "\u001b[0;32mD:\\Anaconda3\\lib\\site-packages\\sklearn\\utils\\extmath.py\u001b[0m in \u001b[0;36mstable_cumsum\u001b[0;34m(arr, axis, rtol, atol)\u001b[0m\n\u001b[1;32m    758\u001b[0m         \u001b[1;32mreturn\u001b[0m \u001b[0mnp\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mcumsum\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0marr\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0maxis\u001b[0m\u001b[1;33m=\u001b[0m\u001b[0maxis\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mdtype\u001b[0m\u001b[1;33m=\u001b[0m\u001b[0mnp\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mfloat64\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m    759\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m--> 760\u001b[0;31m     \u001b[0mout\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mnp\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mcumsum\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0marr\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0maxis\u001b[0m\u001b[1;33m=\u001b[0m\u001b[0maxis\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mdtype\u001b[0m\u001b[1;33m=\u001b[0m\u001b[0mnp\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mfloat64\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m    761\u001b[0m     \u001b[0mexpected\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mnp\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0msum\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0marr\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0maxis\u001b[0m\u001b[1;33m=\u001b[0m\u001b[0maxis\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mdtype\u001b[0m\u001b[1;33m=\u001b[0m\u001b[0mnp\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mfloat64\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m    762\u001b[0m     if not np.all(np.isclose(out.take(-1, axis=axis), expected, rtol=rtol,\n",
      "\u001b[0;32mD:\\Anaconda3\\lib\\site-packages\\numpy\\core\\fromnumeric.py\u001b[0m in \u001b[0;36mcumsum\u001b[0;34m(a, axis, dtype, out)\u001b[0m\n\u001b[1;32m   2115\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m   2116\u001b[0m     \"\"\"\n\u001b[0;32m-> 2117\u001b[0;31m     \u001b[1;32mreturn\u001b[0m \u001b[0m_wrapfunc\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0ma\u001b[0m\u001b[1;33m,\u001b[0m \u001b[1;34m'cumsum'\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0maxis\u001b[0m\u001b[1;33m=\u001b[0m\u001b[0maxis\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mdtype\u001b[0m\u001b[1;33m=\u001b[0m\u001b[0mdtype\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mout\u001b[0m\u001b[1;33m=\u001b[0m\u001b[0mout\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m   2118\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m   2119\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n",
      "\u001b[0;32mD:\\Anaconda3\\lib\\site-packages\\numpy\\core\\fromnumeric.py\u001b[0m in \u001b[0;36m_wrapfunc\u001b[0;34m(obj, method, *args, **kwds)\u001b[0m\n\u001b[1;32m     55\u001b[0m \u001b[1;32mdef\u001b[0m \u001b[0m_wrapfunc\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mobj\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mmethod\u001b[0m\u001b[1;33m,\u001b[0m \u001b[1;33m*\u001b[0m\u001b[0margs\u001b[0m\u001b[1;33m,\u001b[0m \u001b[1;33m**\u001b[0m\u001b[0mkwds\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m     56\u001b[0m     \u001b[1;32mtry\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m---> 57\u001b[0;31m         \u001b[1;32mreturn\u001b[0m \u001b[0mgetattr\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mobj\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mmethod\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m*\u001b[0m\u001b[0margs\u001b[0m\u001b[1;33m,\u001b[0m \u001b[1;33m**\u001b[0m\u001b[0mkwds\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m     58\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m     59\u001b[0m     \u001b[1;31m# An AttributeError occurs if the object does not have\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
      "\u001b[0;31mKeyboardInterrupt\u001b[0m: "
     ]
    }
   ],
   "source": [
    "for i in range(1000):\n",
    "    kmeans = KMeans(n_clusters=110, init='k-means++', n_init=10).fit(X)\n",
    "    score = silhouette_score(X, kmeans.labels_)\n",
    "    print(\"%-5s%-10s\" % (i, score))\n",
    "    if(score > 0.2): \n",
    "        break"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {
    "collapsed": true
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "100  -0.0246025864627\n",
      "101  -0.0176424222517\n",
      "102  -0.0107316360997\n",
      "103  -0.0105101993954\n",
      "104  -0.0243005482373\n",
      "105  -0.0282446384576\n",
      "106  -0.0209915587658\n",
      "107  -0.0263957079756\n",
      "108  0.00251624278298\n",
      "109  0.000144768324982\n",
      "110  -0.0137613106569\n",
      "111  0.0258296500248\n",
      "112  -0.0186503380032\n",
      "113  0.0269006185755\n",
      "114  -0.0345925746061\n",
      "115  0.0455515479034\n",
      "116  -0.0086582966173\n",
      "117  0.00409678623544\n",
      "118  -0.0338496963551\n",
      "119  -0.0236896877977\n",
      "120  -0.0137399586261\n",
      "121  -0.0293370034487\n",
      "122  -0.01145312968\n",
      "123  -0.0167496004543\n",
      "124  -0.00948025707689\n",
      "125  -0.0188668013758\n",
      "126  -0.0125087088963\n",
      "127  0.0118753930936\n",
      "128  -0.0305148667929\n",
      "129  -0.017675019164\n",
      "130  -0.00836216114276\n",
      "131  -0.0137678747726\n",
      "132  -0.0356356507468\n",
      "133  -0.0292700832353\n",
      "134  -0.0153638368406\n",
      "135  -0.0358530053893\n",
      "136  -0.0585070238783\n",
      "137  -0.0177836639407\n",
      "138  0.0103270289056\n",
      "139  -0.0140430552704\n",
      "140  -0.0152871885744\n",
      "141  0.017779142171\n",
      "142  -0.0554852369368\n",
      "143  -0.0229843999011\n",
      "144  -0.00490301648938\n",
      "145  -0.0140438271615\n",
      "146  -0.014915143285\n",
      "147  -0.000935049852126\n",
      "148  -0.0246227115225\n",
      "149  -0.0200729399854\n"
     ]
    }
   ],
   "source": [
    "# 寻找最佳ncluster\n",
    "for ncluster in range(100, 150):\n",
    "    kmeans = KMeans(n_clusters=ncluster, init='k-means++', n_init=5).fit(X)\n",
    "    score = silhouette_score(X, kmeans.labels_)\n",
    "    print(\"%-5s%-10s\" % (ncluster, score))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 33,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "# 将聚类结果保存下来\n",
    "n_clusters = 115\n",
    "fouts = []\n",
    "for i in range(n_clusters):\n",
    "    fout= open(\"./positions_kmeans_result/0928/topic\"+str(i+1)+\".txt\", \"w\", encoding=\"utf-8\")\n",
    "    fouts.append(fout)\n",
    "    \n",
    "index = 0\n",
    "for label in kmeans.labels_:\n",
    "    fouts[label-1].write(index2word[index])\n",
    "    fouts[label-1].write(\"\\n\")\n",
    "    index += 1\n",
    "for fout in fouts:\n",
    "    fout.close()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 34,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "# 将聚类结果保存为一个文件\n",
    "with open(\"./positions_kmeans_result/positions_labeled_115_0928.txt\", \"w\", encoding=\"utf-8\") as fo:\n",
    "    index = 0\n",
    "    for label in kmeans.labels_:\n",
    "        # print(index2word[index],label)\n",
    "        fo.write(index2word[index] + \" \" + str(label))\n",
    "        fo.write(\"\\n\")\n",
    "        index += 1"
   ]
  }
 ],
 "metadata": {
  "anaconda-cloud": {},
  "kernelspec": {
   "display_name": "Python [default]",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.5.2"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 1
}
